Last active
May 19, 2018 13:39
-
-
Save code-shoily/5a0db66985f076ebb497ea226a0f15d0 to your computer and use it in GitHub Desktop.
[Based off my Facebook Post in Python Bangladesh, the Admin Quiz #2] Make an Admin for the Category model, following the rules and specifications mentioned in the post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Category(models.Model): | |
name = models.CharField(max_length=31) | |
def __str__(self): | |
return f"{self.name}" | |
class Meta: | |
verbose_name_plural = "categories" | |
class Product(models.Model): | |
category = models.ForeignKey(Category, on_delete=models.CASCADE) | |
name = models.CharField(max_length=31) | |
price = models.DecimalField(max_digits=10, decimal_places=2) | |
def __str__(self): | |
return f"{self.name}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment