1. David Jean Louis
  2. django-admin-tools
  3. Issues
Issue #93 new

Bookmark.user, DashboardPreferences.user related_name collision

lettertwo
created an issue

The {{{Bookmark}}} and {{{DashboardPreferences}}} models both have foreign keys to the Django auth {{{User}}} model. They are using default {{{related_name}}} values, which increases the likelihood of collision.

In my particular case, the collision happens with Sentry's {{{GroupBookmark}}} model, which also has a foreign key to {{{User}}}.

Since the {{{User}}} model does not belong to admin-tools, maybe the {{{related_name}}} values should be "namespaced" in some way, such as admin_tools_bookmark_set and admin_tools_dashboard_preferences_set?

=== Requirements: ===

{{{ Django==1.3.1 sentry==2.0.0 django-admin-tools==0.4.1 }}}

=== Error message: ===

{{{ Error: One or more models did not validate: menu.bookmark: Accessor for field 'user' clashes with related field 'User.bookmark_set'. Add a related_name argument to the definition for 'user'. sentry.groupbookmark: Accessor for field 'user' clashes with related field 'User.bookmark_set'. Add a related_name argument to the definition for 'user'. sentry.groupbookmark: Reverse query name for field 'user' clashes with related field 'User.bookmark_set'. Add a related_name argument to the definition for 'user'. }}}

EDIT: I've also opened an [[https://github.com/dcramer/sentry/issues/323|issue over at Sentry]].

Comments (4)

  1. David Jean Louis repo owner

    Well, while I agree a related name would reduce the risk of collision, the question here is why sentry has a "User.bookmark_set" when the class name is "groupbookmark", collision would not have happened if the related_name had been untouched.

    I'm changing this as a feature.

    Regards,

    -- David

  2. lettertwo reporter

    Thanks for taking a look!

    Sentry has been patched to avoid this particular collision, however I think it may be a good idea for admin_tools to make the change, as well. In particular, Bookmark seems like a common enough model name that some extra collision protection might really be of use.

  3. Log in to comment