Hello, normal schema for a blog app, entry and tag class :

TAG
class Tag(models.Model):
        name = models.CharField(maxlength=200, core=True)
        total_ref = models.IntegerField(blank=True, null=True)

        class Admin:
                ordering = ['name']

        def __str__(self):
                return self.name

        def get_absolute_url(self):
                return "/blog/tag/%s/" % (self.name)

ENTRY
class Entry(models.Model):
        [...]
        tags = models.ManyToManyField(Tag)
        [...]

        class Admin:
                pass

        def __str__(self):
                return self.title

        def get_absolute_url(self):
                return "/blog/%s/%s/" % 
(self.created.strftime("%Y/%b/%d").lower(),
self.slug)

This creates 3 tables
   blog_entry
   blog_entry_tags
   blog_tag

with   blog_entry_tags being id, entry_id, tag_id


-> what i want to achieve :
when en entry is added via admin form, you add tags or select already
existing ones to the entry.
Every time, an entry get added to  blog_entry_tags. thats when i want
to set total_ref attribute of Tag to +1 (keep a track of how many entry
use a tag)

Where and how to do this ? not in class Tag(models.Model): since the
def(save) get called only when you add an entre to blog_tag  not to
blog_entry_tags  .

thanks for your help


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to