1đź‘Ť
Proxy = True
means that there is no actual database table created for the model. So, when you try to reference the model with a ForeignKey, things break (since the ForeignKey has no db table to point to).
If what you are trying to achieve is to have a “Generic abstract” type object with concrete sub-type and want a foreign-key to any of the sub-types I would recommend checking out https://docs.djangoproject.com/en/1.8/ref/contrib/contenttypes/#generic-relations (with a custom limit_choices_to on the ForeignKey to ContentType https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to)
You might also be interested in Django Polymorphic (https://django-polymorphic.readthedocs.org/en/latest/) which does all that and more.
1đź‘Ť
If this is happening in tests as it does for me,
maybe this link
can help, in short the answer is:
Ok, I found a way around the problem, in case anyone ever has the same
problem. If you specifyTEST_DATABASE_NAME
in your settings, it will
force sqllite to use a file database instead of in-memory database,
and then the problem goes.
- Django Testing: Does –keepdb reset changes made during tests?
- Python – pyodbc call stored procedure with parameter name
- Django dependent select
- Docker-compose to run django with mongodb