Top "Django-models" questions

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

How can I temporarily disable a foreign key constraint in MySQL?

Is it possible to temporarily disable constraints in MySQL? I have two Django models, each with a foreign key to …

mysql sql django django-models
How do I do a not equal in Django queryset filtering?

In Django model QuerySets, I see that there is a __gt and __lt for comparative values, but is there a __…

python django django-models django-queryset
Filtering for empty or NULL names in a queryset

I have first_name, last_name & alias (optional) which I need to search for. So, I need a query …

django django-models django-queryset filter null
How to query as GROUP BY in django?

I query a model: Members.objects.all() And it returns: Eric, Salesman, X-Shop Freddie, Manager, X2-Shop Teddy, Salesman, X2…

python django django-models
How to delete a record in Django models?

I want to delete a particular record. Such as delete from table_name where id = 1; How can I do this …

python django django-models
How do I filter query objects by date range in Django?

I've got a field in one model like: class Sample(models.Model): date = fields.DateField(auto_now=False) Now, I …

python django django-models django-queryset
differentiate null=True, blank=True in django

When we add a database field in django we generally write: models.CharField(max_length=100, null=True, blank=True) The …

python django django-models
Django auto_now and auto_now_add

For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True) …

python django datetime django-models django-admin
Django set default form values

I have a Model as follows: class TankJournal(models.Model): user = models.ForeignKey(User) tank = models.ForeignKey(TankProfile) ts = models.…

python django django-models django-forms
What does on_delete do on Django models?

I'm quite familiar with Django, but I recently noticed there exists an on_delete=models.CASCADE option with the models. …

python django django-models