Files
Django-Test/post/models.py

18 lines
625 B
Python

from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=75)
body = models.TextField()
slug = models.SlugField()
date = models.DateTimeField(auto_now_add=True)
banner = models.ImageField(default='fallback.png', blank=True)
author = models.ForeignKey(User, on_delete=models.CASCADE, default=None) #Kritisch wenn conus medical products are linked to User.objects.get(username='root')company and compony is deleted all products are deleted.
def __str__(self):
return self.title