6
As Rebus says in the comments, you don’t need to define the primary key explicitly. But if you do, you must make sure it is an autoincrement field – ie AutoField
– not a basic IntegerField
as you have. The way you have it, there’s no way to get a new ID, which is why it’s blank on save.
0
System generated database keys must be set by the database or else you won’t have a multi-user database.
- [Django]-Define component schema with drf-spectacular for django API
- [Django]-Django pagination with dictionary where key is a list
Source:stackexchange.com