mirror of
https://github.com/DerTyp7/tealcode-django-python.git
synced 2025-10-30 12:57:07 +01:00
added models
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
from django.db import models
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
from django.utils import timezone
|
||||
|
||||
# Create your models here.
|
||||
class Category(models.Model):
|
||||
title = models.CharField(max_length=100, unique=True)
|
||||
date_created = models.DateTimeField(default=timezone.now)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
||||
class Topic(models.Model):
|
||||
title = models.CharField(max_length= 200)
|
||||
code_text = models.TextField()
|
||||
date_created = models.DateTimeField(default=timezone.now)
|
||||
category = models.ForeignKey(Category, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.category.title + " - " + self.title
|
||||
|
||||
Reference in New Issue
Block a user