set primary key in django model code example
Example 1: primary key django model
class Garden(models.Model):
garden_id = models.IntegerField(primary_key=True)
Example 2: django models
Models in Django are classes that represent data base tables.
Example 3: django custom primary key field
import uuid
from django.db import models
class MyUUIDModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
# other fields