Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django_markdown.models import MarkdownField
- from django.utils.text import slugify
- class Board(models.Model):
- name = models.CharField(max_length=50)
- created = models.DateTimeField(auto_now_add=True)
- modified = models.DateTimeField(auto_now=True)
- def __str__(self):
- return self.name
- class Notice(models.Model):
- title = models.CharField(max_length=100, blank=False, unique=True)
- created = models.DateTimeField(auto_now_add=True)
- body = models.TextField()
- slug = models.SlugField(null=True, blank=True)
- board= models.ManyToManyField(Board)
- body = MarkdownField()
- """returns the title of the notice """
- def __str__(self):
- return self.title
- def save(self, *args, **kwargs):
- if not self.id:
- # Newly created object, so set slug
- self.s = slugify(self.title)
- super(Notice, self).save(*args, **kwargs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement