model pk django code example
Example 1: create models in django
from django.db import models
# Create your models here.
class Contact(models.Model):
name = models.CharField(max_length=50)
email = models.CharField(max_length=50)
contact = models.CharField(max_length=50)
content = models.TextField()
def __str__(self):
return self.name + ' ' + self.email
Example 2: .save() in django
>>> one_entry = Entry.objects.get(pk=1)
Example 3: pk django
pk is short for primary key, which is a unique identifier for each
record in a database.