class Subject(models.Model):
module = models.ForeignKey(Module)
}}}
And this Admin Class:
{{{
class SubjectAdmin(admin.ModelAdmin):
search_fields = ('module__name',)
}}}
And i'm getting this error
FieldError at /admin/app/subject/
Relation fields do not support nested lookups
on django\db\models\fields\related.py in get_lookup_constraint
raise exceptions.FieldError('Relation fields do not support nested
lookups')
--
Ticket URL: <https://code.djangoproject.com/ticket/23351>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
I can't reproduce this with the information provided and using a simple
setup containing only the code shown by the OP.
Reopne if you can post more details.
--
Ticket URL: <https://code.djangoproject.com/ticket/23351#comment:1>
* cc: florent.pastor@… (added)
Comment:
I have a similar issue, except that my model is slightly more complex. The
{{{Module}}} class inherit from another one, and I use a
{{{ManyToManyField}}}, instead of a {{{ForeignKey}}}.
{{{
class Base(models.Model):
name = models.CharField(max_length=100)
class Module(Base):
pass
class Subject(models.Model):
module = models.ManyToManyField(Module)
}}}
The admin class is still the same :
{{{
class SubjectAdmin(admin.ModelAdmin):
search_fields = ('module__name',)
}}}
When I try to search, I get this issue :
{{{
Django Version: 1.6.5
Exception Type: TypeError
Exception Value:
Related Field got invalid lookup: icontains
Exception Location: /usr/local/lib/python2.7/dist-
packages/django/db/models/fields/related.py in get_lookup_constraint, line
1123
Python Executable: /usr/bin/python
Python Version: 2.7.6
}}}
By the way, I run Django 1.6.5, I did not test my project under django
1.7.
--
Ticket URL: <https://code.djangoproject.com/ticket/23351#comment:2>
* status: closed => new
* severity: Release blocker => Normal
* cc: zeraien (added)
* type: Uncategorized => Bug
* version: 1.7-rc-2 => 1.7
* resolution: worksforme =>
Comment:
Replying to [comment:1 ramiro]:
> I can't reproduce this with the information provided and using a simple
setup containing only the code shown by the OP.
>
> Reopne if you can post more details.
I discovered the problem seems to be related to this ticket:
https://code.djangoproject.com/ticket/23697
If using this: `search_fields = ('module__name',)` but `name` does not
exist in the `module` model, this error is thrown.
Using django 1.7.3
Full trace: https://gist.github.com/anonymous/f9abcb78c77466c35dcb
--
Ticket URL: <https://code.djangoproject.com/ticket/23351#comment:3>
* status: new => closed
* type: Bug => Cleanup/optimization
* resolution: => duplicate
Comment:
Thanks for the report but let's keep this ticket closed by marking it as a
duplicate instead and move all discussion to #23697.
The fix suggested by Tim on #23697 should prevent reports similar to this
one which were probably caused by a simple typo in the field name.
--
Ticket URL: <https://code.djangoproject.com/ticket/23351#comment:4>