'Why can't I use SoftDeletableModel and TimeFramedModel together in Django model?
I need a model that should be soft deletable (not actually deleting from DB) and should have start and end timestamps.
I've used SoftDeletableModel and TimeFramedModel from django-model-utils library for this purpose.
This is my models.py
from model_utils.models import TimeFramedModel, SoftDeletableModel
class Quiz(SoftDeletableModel, TimeFramedModel):
"""
Model for quiz
"""
total_questions = models.PositiveSmallIntegerField(_("Total no of questions"))
duration = models.PositiveSmallIntegerField(_("Duration (in mins)"))
This works fine in shell as well as in the APIs. But I'm not able to see any data in Django admin. I tried using one of them at a time, and it works fine.
I checked the data using shell as below:
>>> from apps.quiz.models import Quiz
>>> Quiz.objects.all()
<SoftDeletableQuerySet [<Quiz: Mathematics Quiz>, <Quiz: Mathematics Weekly Quiz>, <Quiz: Monday GK Quiz>]>
And this is what I see in Django admin:
Now I've two questions here:
- What is the reason I get no data in admin panel when using both together?
- How can solve this issue while using these prebuilt model classes only? (If its possible)
Any help is really appreciated. Thank You !!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

