[Answered ]-How do I put an ID?

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)

Leave a comment