Skip to content

Extend the django subclass system. For proxy class, allow to retrieve the object with the proxy class (not the base class). On subclass, enable to retrieve objects through the base class with their real types

anthony-tresontani/django-subclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django_subclass

If a subclass S1 of the base class B is created:
    django_subclass allow to perform B.objects.all() and to retrieve object of type S1

If a proxy P1 of the base class B is created:
    django_subclass allow to perform B.object.get() retrieve an object of type S1

Usage:

    1 - Add the django_subclass folder to your PYTHON_PATH and installed_apps
    2 - Register your model:
        site.register(SubClassA)

    3 - That's it

    
    Before :
        >>> A = SubClassA(key=1)
        >>> BaseClass.objects.get(key=1).__class__
        <class 'test_app.models.BaseClass'>

    After :
        >>> A = SubClassA(key=1)
        >>> BaseClass.objects.get(key=1).__class__
        <class 'test_app.models.SubClassA'>

About

Extend the django subclass system. For proxy class, allow to retrieve the object with the proxy class (not the base class). On subclass, enable to retrieve objects through the base class with their real types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages