Hi,

John Sutherland wrote:

> class BlogPost(models.Model):
>      categories = models.ManyToManyField(Category)
> 
> It may be worth having a look at the generic relationships [1] stuff
> and the Tag application used as an example. While the GR stuff in the
> Django admin is truly horrible, you can easily write a couple of
> views and maybe a custom manipulator to tidy things up.
> 
> [1] <http://www.djangoproject.com/documentation/models/
> generic_relations/>

What the pros & cons for each method ?

As the generic relation lacks of some explaination :
- do we necessary import "content type" contrib ?
- do we necessary need to add in first object :
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = models.GenericForeignKey()
- What would be the difference between :

class TaggedItem(models.Model):
    """A tag on an item."""
    tag = models.SlugField()
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = models.GenericForeignKey()

class Animal(models.Model):
    common_name = models.CharField(maxlength=150)
    latin_name = models.CharField(maxlength=150)
    tags = models.GenericRelation(TaggedItem)

and :

class TaggedItem(models.Model):
    """A tag on an item."""
    tag = models.SlugField()

class Animal(models.Model):
    common_name = models.CharField(maxlength=150)
    latin_name = models.CharField(maxlength=150)
    tags = models.ManyToManyField(TaggedItem)

??

Thanks in advance,
Nicolas


--~--~---------~--~----~------------~-------~--~----~
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