Creating the Item model
Let’s continue by creating an Item
model and follow these steps:
- Create the Item model.
- Apply migrations.
- Add the item model to the admin panel.
Creating the Item model
In /cart/models.py
file, add the following in bold:
from django.db import models from django.contrib.auth.models import User from movies.models import Movie class Order(models.Model): … class Item(models.Model): id = models.AutoField(primary_key=True) price = models.IntegerField() quantity = models.IntegerField() order = models.ForeignKey(Order, on_delete=models.CASCADE) movie = models.ForeignKey(Movie, on_delete=models.CASCADE) def __str__(self): &...