Accessor for field 'user' clashes with related field 'User.*'

651 views
Skip to first unread message

lcordier

unread,
Oct 22, 2008, 6:09:21 AM10/22/08
to Django users
I have recently changed the layout of my code. Putting all my apps
into an apps sub-directory to make things a bit cleaner. Basically the
same layout as http://code.djangoproject.com/browser/djangoproject.com/django_website/apps

To run my tests I have to go into the apps sub-directory and run it
like so:
../manage.py test app

The problem, now all foreign key's result in:
apps/profiles.userprofile: Accessor for field 'user' clashes with
related field 'User.lala_set'. Add a related_name argument to the
definition for 'user'.
apps/profiles.userprofile: Reverse query name for field 'user' clashes
with related field 'User.lala_set'. Add a related_name argument to the
definition for 'user'.

No matter what 'related_name' I choose, I mean no clashes with other
tables.
My questions:

1. How does test work for django_website?
2. Anyone else with a non-standard apps layout, with a solution to
this problem?

Regards, Louis.

Peter Bengtsson

unread,
Oct 22, 2008, 1:42:56 PM10/22/08
to Django users
I don't see what splitting it up into "sub apps" has anything to do
with it?
What happens when you add the related_name attribute to your model
fields?
Here's some code from one of my apps:

class M(models.Model):
...
from_user = models.ForeignKey(User, null=True,
related_name='from')
to_user = models.ForeignKey(User, null=True, related_name='to')


On Oct 22, 11:09 am, lcordier <lcord...@gmail.com> wrote:
> I have recently changed the layout of my code. Putting all my apps
> into an apps sub-directory to make things a bit cleaner. Basically the
> same layout ashttp://code.djangoproject.com/browser/djangoproject.com/django_websit...

lcordier

unread,
Oct 23, 2008, 6:31:28 AM10/23/08
to Django users
Found the bug in settings.py, one of the installed apps had a little
mistake.
Was 'apps/app' instead of 'apps.app'.
Reply all
Reply to author
Forward
0 new messages