Skip to content

Instantly share code, notes, and snippets.

@code-shoily
Last active May 19, 2018 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-shoily/5a0db66985f076ebb497ea226a0f15d0 to your computer and use it in GitHub Desktop.
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.
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