I am using the django-polymorphic package: https://pypi.org/project/django_polymorphic/
I was looking at the documentation for Proxy Models in the docs: https://docs.djangoproject.com/en/1.11/topics/db/models/#proxy-models
Initial Setup - I tried the following with the regular django model class:
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
class MyPerson(Person):
class Meta:
proxy = True
def do_something(self):
# ...
pass
Python Console:
>>> p = Person.objects.create(first_name="foobar")
>>> p
<Person: Person object (4)>
>>> MyPerson.objects.all()
<QuerySet [<MyPerson: MyPerson object (4)>]>
However, when I tried using the PolymorphicModel from django-polymorphic on the Person Class and attempt the same commands, I get an empty queryset.
Changed Person Model
class Person(PolymorphicModel):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
Python Console:
>>> p = Person.objects.create(first_name="foobar")
>>> MyPerson.objects.all()
<PolymorphicQuerySet []>
Shouldn't we expect the Queryset to contain the Person object we created?
My end goal is to create proxy models to register with two different Django Admin pages.
Thanks!