Tag

tips

Posts

Working With Custom Primary Key in Django Models

Working With Custom Primary Key in Django Models

1 min readRitij Jain

Django adds an auto-incrementing id field when a model has no explicit primary key. A lookup such as get object or 404(MyModel, pk=1) looks for the row whose primary key is 1 . It returns a 404 if tha…