On Saturday, September 7, 2013 6:52:14 AM UTC+3, Mark Young wrote:
>
> For a little bit of context, here's an example of code that perviously 
> worked but now doesn't:
>
> class CategoryAdminForm(forms.ModelForm):
>     """Form for Category's Admin"""
>     parent = TreeNodeChoiceField(
>     label=_('Parent category'),
>     level_indicator='|--', required=False,
>     empty_label=_('No parent category'),
>     queryset=Category.objects.all())
>
>     def __init__(self, *args, **kwargs):
>         super(CategoryAdminForm, self).__init__(*args, **kwargs)
>         rel = ManyToOneRel(Category, 'id')
>         self.fields['parent'].widget = RelatedFieldWidgetWrapper(
>             self.fields['parent'].widget, rel, self.admin_site)
>

Seems to be the other side of the relation. So, you need the foreign key 
pointing to Category.id, from the above code it isn't obvious what that 
field is. Maybe something like Category._meta.get_field('parent_id') is 
correct?

This might allow both 1.5 and 1.6 to work:
     if django's version is 1.6:
        rel = ManyToOneRel(Category._meta.get_field('parent_id'), Category, 
'id')
    else:
        rel = ManyToOneRel(Category, 'id')

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to