Top "Django-models" questions

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

Django: Get list of model fields?

I've defined a User class which (ultimately) inherits from models.Model. I want to get a list of all the …

django django-models
Create Django model or update if exists

I want to create a model object, like Person, if person's id doesn't not exist, or I will get that …

python django django-models
Django error - matching query does not exist

I finally released my project to the production level and suddenly I have some issues I never had to deal …

database django django-models production
Default value for field in Django model

Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.CharField(max_length=10) …

python django django-models django-admin
Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?

I have a Person model that has a foreign key relationship to Book, which has a number of fields, but …

python django django-models django-admin modeladmin
How to set True as default value for BooleanField on Django?

I am using BooleanField in Django. By default, the checkbox generated by it is unchecked state. I want the state …

python django django-models
How do you serialize a model instance in Django?

There is a lot of documentation on how to serialize a Model QuerySet but how do you just serialize to …

python django json django-models serialization
Django values_list vs values

In Django, what's the difference between the following two: Article.objects.values_list('comment_id', flat=True).distinct() vs Article.…

django django-models django-queryset django-orm
Programmatically saving image to Django ImageField

Ok, I've tried about near everything and I cannot get this to work. I have a Django model with an …

python django django-models