Hi,

I'm trying to modify my blogging application using the new
GenericRelation and GenericForeignKey, keeping the tagging concept as
easy as posible.

The problem is, once the modifications made, I can not find a tag
field in the Admin interface. It says "Could not find Formfield or
InlineObjectCollection named 'tags'". The doc is yet a bit light on
this, so I can not find any info.

Is it normal? Is there a way of circunventing this?

Thanks,

G

The code:

class Tag(models.Model):
    slug=models.SlugField(prepopulate_from=('title',),
                          help_text='Automatically built from the title',
                          primary_key=True)
    title = models.CharField(maxlength=30)
    description=models.CharField(maxlength=200,help_text='Short
summary of this tag')
    tagged_obj=models.GenericForeignKey()

    def get_absolute_url(self):
        return '/tags/%s/' % self.slug

    def get_list(self):
        return self.post_tagged.all()

    def __str__(self):
        return self.title

    def __repr__(self):
        return self.title

    class Admin:
        list_display = ('title','description')
        search_fields = ('title','description')
        fields = ((None, {'fields':('title','description','slug'),}),)



class Post(models.Model):
    slug = models.SlugField(prepopulate_from=('title',),
                          help_text='Automatically built from the title',
                          primary_key=True)
    title = models.CharField(maxlength=79)
    creation_date = models.DateTimeField(auto_now=True)
    body = models.TextField('Body Text')
    summary = models.TextField(maxlength=300,
                               blank=True,
                               help_text='Will be displayed on article indexes'+
                               'if it exists, otherwise full body will be used')
    tags = models.GenericRelation(Tag)
    image = models.ImageField('Attach Image',
                               upload_to='sysvortex/blog',
                               blank=True)
    author = models.ForeignKey(User)
    to_publish = models.BooleanField(default=False,
                                   help_text='Draft entries are visible only'+
                                   'to the authors and admins',
                                   radio_admin=True)
    enable_comments = models.BooleanField(default=True)

    def get_absolute_url(self):
        return '/blog/%s/%s/' %
(self.creation_date.strftime('%Y/%m/%d').lower(),
                                 self.slug)
    def get_tag_list(self):
        return self.tags.all()
        
    def __str__(self):
        return self.title

    def __repr__(self):
        return self.title

    class Admin:
        list_display =
('title','creation_date','author','to_publish','enable_comments')
        list_filter = ['creation_date','enable_comments']
        date_hierarchy = 'creation_date'
        list_select_related = 'True'
        search_fields = ['title','summary','body']
        ordering = ('-creation_date','to_publish')
        js = ('tiny_mce/tiny_mce.js',
              'js/admin/textareas.js',)
        fields = (
            (None, {'fields':('title','to_publish','enable_comments'),}),
            ('Other information', {'fields':('slug','author','creation_date'),
                                   'classes': 'collapse'}),
            ('Post', {'fields':('summary','image','body',),
                      'classes':'wide', }),
            )

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