I'm having a little trouble tracking a down a small problem. My models
(which are working) look like this (with some of the boilerplate cut
out):

class Image(models.Model):
        id = models.AutoField(primary_key=True)
        pub_date = models.DateTimeField(blank=True)
        caption = models.TextField(blank=True)
        location = models.CharField(blank=True, max_length=150)
        portfolios = models.ManyToManyField(Portfolio, db_table='set_image',
blank=True)

        def __unicode__(self):
                return u"%s | %s" % (self.caption, self.location)
        class Meta:
                db_table = 'image'
                ordering = ('-pub_date',)

class Portfolio(models.Model):
        id = models.AutoField(primary_key=True)
        name = models.CharField(blank=True, max_length=150)
        description = models.CharField(blank=True, max_length=300)

        class Meta:
                db_table = 'sets'
        def __unicode__(self):
                return self.name

class ImagePort(models.Model):
        # Merge table to add data (Rank for ordering) to many-to-many
relationship between Image and Portfolio
        portfolio = models.ForeignKey(Portfolio, blank=False, default=None)
        image = models.ForeignKey(Image, blank=False, default=None)
        rank = models.IntegerField(null=True, blank=True)

        class Meta:
                db_table = 'set_image'
                ordering = ('rank',)


and in an admin.py file I have:

class ImageAdmin(admin.ModelAdmin):
        ordering = ['id']
        filter_horizontal = ('portfolios',)

admin.site.register(Image, ImageAdmin)

This works fine even after upgrading to 1.0. But when I follow the new
docs and change my Image model's many-to-many definition to:

portfolios = models.ManyToManyField(Portfolio, through="ImagePort",
blank=True)

I lose the many-to-many portfolios with the nifty filter_horizontal in
the Image admin. I can get the admin.TabularInline interface by
following the docs, but like most people I really prefer the nifty
javascript version. If I try to add the portfolio with something like
fields=('portfolios',) in the ImageAdmin I get a template syntax error
complaining that the key 'portfolio' is not found.

Am I doing something obviously wrong?

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to