from django.db import models from saudade.common.help import markdown from datetime import datetime # Create your models here. class Photographer(model.Model): name = models.CharField(maxlength=100) url = models.CharField(maxlength=200) class Gallery(models.Model): title = models.CharField(maxlength=100) slug = models.SlugField(maxlength=100, prepopulate_from=('title',), unique=True) description = models.TextField(help_text=markdown, blank=True) private = models.BooleanField() photographer = models.ForeignKey(Photographer) def get_absolute_url(self): return '/' class Photo(models.Model): gallery = models.ForeignKey(Gallery) tags = models.ManyToManyField(Tag) summary = models.TextField(help_text=markdown, blank=True) author = models.ForeignKey(User) enable_comments = models.BooleanField(default=True) class Admin: fields = ( ('Blog post', {'fields': ('title', 'slug', 'body')}), ('Publishing data', {'fields': ('author', 'is_published', 'enable_comments', 'pub_date', 'tags')}), ) list_display = ('title', 'pub_date', 'is_published') search_fields = ('title', 'slug', 'body', 'summary') list_filter = ('pub_date', 'is_published', 'enable_comments') class Meta: ordering = ['-pub_date'] get_latest_by = '-pub_date' def __str__(self): return "%s" % (self.title) def get_absolute_url(self): return "/gallery/" def get_admin_url(self): return "/admin/blog/post/"