1👍
By default, Django use a hidden primary key field, an integer, that is autoincremented. If you want to use another field type, for example CharField()
, you need to add the primary_key=True
to that CharField
. Example:
class Category2(models.Model):
id = models.CharField(max_length=32, primary_key=True)
# ...
Source: Automatic primary key fields
0👍
By default, Django gives each model the following field: id = models.AutoField (primary_key=True) This is an auto-incrementing primary key. So for your case is: city_id = models.AutoField (primary_key=True)
- [Answered ]-Send Model Data through AJAX in Django
- [Answered ]-Guest Checkout in django
- [Answered ]-Filterig initial data in Django ManyToMany field
Source:stackexchange.com