1class Garden(models.Model):
2 garden_id = models.IntegerField(primary_key=True)
1from django.db import models
2# Create your models here.
3
4class Contact(models.Model):
5 name = models.CharField(max_length=50)
6 email = models.CharField(max_length=50)
7 contact = models.CharField(max_length=50)
8 content = models.TextField()
9 def __str__(self):
10 return self.name + ' ' + self.email
1# All Django Class Meta Attributes
2abstract
3app_label
4base_manager_name
5db_table
6Table names
7db_tablespace
8default_manager_name
9default_related_name
10get_latest_by
11managed
12order_with_respect_to
13ordering
14permissions
15default_permissions
16proxy
17required_db_features
18required_db_vendor
19select_on_save
20indexes
21unique_together
22index_together
23constraints
24verbose_name
25verbose_name_plural
1The ID in django is a "unique identifier" for each models instances.
2You do not need to explicitly add a ID field to your own models as
3the ID attribute is automatically generated for you behind the scences
4by django for each new model and any newly created instances of that
5model afterwards.
1poll = models.ForeignKey(
2 Poll,
3 on_delete=models.CASCADE,
4 verbose_name="the related poll",
5)
6sites = models.ManyToManyField(Site, verbose_name="list of sites")
7place = models.OneToOneField(
8 Place,
9 on_delete=models.CASCADE,
10 verbose_name="related place",
11)
12