There are times when, you want to handle multiple Django models in a single POST request (By this i meant data posted from html form/ template contains data of two different Django models). I was struggling with this few months back and got a fantastic reference link from #django on IRC. You can use the below method as … Continue reading Handling two Django models in a single POST
django-userena: User Management Application for Django.
Source: django-userena: User Management Application for Django.
Django – AttributeError: ‘Http404’ object has no attribute ‘status_code’
If you getting this error, it might be because you are returning Http404 instead of raising it. you need to raise django.http.Http404, not return it. example code :
Make primary key with two or more field in Django
Most of the time, people don't actually need their composite (multi-column) key to be the primary key. Django operates best with surrogate keys - that is, it automatically defines an autoincrement field called id and sets that to be the primary key. That is suitable for almost all the users. If you then need to enforce … Continue reading Make primary key with two or more field in Django
Count and group by equivalent in Django Queryset
While working on a Django project, I came through a problem. I wanted to select a column & count of that column group by that column from a table. (categoryname & count of items for each category), so in simple SQL it would be as simple as this: Now Django Sub Query for the following given … Continue reading Count and group by equivalent in Django Queryset