On Wed, Nov 11, 2009 at 7:06 AM, django_fo...@codechimp.net <
codech...@gmail.com> wrote:

>
> I have a class, A, that has a ManyToMany reference to another class, B
> like so:
>
>    class B(models.Model):
>        name = models.CharField()
>
>        def __unicode__(self)
>            return self.name
>
>    class A(models.Model):
>        name = models.CharField()
>        bees = models.ManyToManyField(B)
>
>        def __unicode__(self)
>            return self.name
>
>
> And an ModelAdmin setup like:
>    class AAdmin(admin.ModelAdmin):
>        filter_horizontal = ('bees')
>
> Everything works perfectly fine when I run this on my local test
> server.


The code above can't possibly be working fine.  It has several errors --
missing colons, missing parameter on the CharFields, missing comma in the
filter_horizontal specification.  When trimming down from your real code
it's important to verify before posting that what you are posting actually
works and actually still exhibits the problem you are posting about.  The
likelihood of someone taking what you have posted and correcting the errors
while still introducing whatever problem is causing the exception you are
seeing is slim.

However, when I move the code "as-is" to my server and I try
> to add a new 'A', I get the following error:
>    TypeError: unbound method __unicode__() must be called with B
> instance as first argument (got nothing instead)
>
>
Also, please include the complete traceback, not just the error message.  In
the absence of the actual code you are using the traceback at least might
provide enough clues for someone to point in a direction of what the error
might be.  As it is all I can tell you is that the error message indicates
some code is apparently attempting to apply unicode() to the B class instead
of an instance of the B class.  The traceback would show exactly what and
where that code is.

Karen

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to