From 8315186b58e7fb5ff12472eff11fb6e0a789a51e Mon Sep 17 00:00:00 2001 From: Kriti Godey Date: Mon, 5 Jul 2010 23:27:03 +0530 Subject: [PATCH] Edited unicode methods and added some null=True, blank=True constraints. --- admin/base.py | 5 ++++- contrib/penfield/models.py | 7 +++++-- models/nodes.py | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/admin/base.py b/admin/base.py index bdf9f38..457db17 100644 --- a/admin/base.py +++ b/admin/base.py @@ -29,4 +29,7 @@ class EntityAdmin(admin.ModelAdmin): save_on_top = True -admin.site.register(Tag) \ No newline at end of file +class TagAdmin(admin.ModelAdmin): + prepopulated_fields = {"slug": ("name",)} + +admin.site.register(Tag, TagAdmin) \ No newline at end of file diff --git a/contrib/penfield/models.py b/contrib/penfield/models.py index e0b7218..ec8ba69 100644 --- a/contrib/penfield/models.py +++ b/contrib/penfield/models.py @@ -15,13 +15,16 @@ class Blog(Entity, Titled): return Tag.objects.filter(blogentries__blog=self) +register_value_model(Blog) + + class BlogEntry(Entity, Titled): blog = models.ForeignKey(Blog, related_name='entries') author = models.ForeignKey(getattr(settings, 'PHILO_PERSON_MODULE', 'auth.User'), related_name='blogentries') date = models.DateTimeField(default=datetime.now) content = models.TextField() - excerpt = models.TextField() - tags = models.ManyToManyField(Tag, related_name='blogentries') + excerpt = models.TextField(blank=True, null=True) + tags = models.ManyToManyField(Tag, related_name='blogentries', blank=True, null=True) class Meta: ordering = ['-date'] diff --git a/models/nodes.py b/models/nodes.py index a8125ee..1e7622a 100644 --- a/models/nodes.py +++ b/models/nodes.py @@ -108,4 +108,7 @@ class File(View): return response class Meta: - app_label = 'philo' \ No newline at end of file + app_label = 'philo' + + def __unicode__(self): + return self.file.name \ No newline at end of file -- 2.20.1