Top "Django-models" questions

For questions concerning use of the model class from the web framework Django.

How to pull a random record using Django's ORM?

I have a model that represents paintings I present on my site. On the main webpage I'd like to show …

python django django-models
Django dump data for a single model?

Can I perform a dumpdata in Django on just a single model, rather than the whole app, and if so, …

django django-models loaddata dumpdata
Override a form in Django admin

In Django admin I want to override and implement my own form for a model (e.g. Invoice model). I …

python django django-models django-admin django-views
Django ModelForm to have a hidden input

So I have my TagStatus model. I'm trying to make a ModelForm for it. However, my form requires that the …

python django django-models django-forms
Django filter many-to-many with contains

I am trying to filter a bunch of objects through a many-to-many relation. Because the trigger_roles field may contain …

python django django-models many-to-many django-orm
Reload django object from database

Is it possible to refresh the state of a django object from database? I mean behavior roughly equivalent to: new_…

python django django-models
Django - Simple custom template tag example

I have users, videos, topics, criterias and ratings A video has a topic A topic has criterias A user can …

django django-models django-templates
Django: Get model from string?

In Django, you can specify relationships like: author = ForeignKey('Person') And then internally it has to convert the string "Person" …

django django-models
django.db.migrations.exceptions.InconsistentMigrationHistory

When I run python manage.py migrate on my Django project, I get the following error: Traceback (most recent call …

python django django-models django-rest-framework database-migration