Bookmark.user, DashboardPreferences.user related_name collision

lettertwo avatarlettertwo 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 issue over at Sentry.

Comments (4)

  1. David Jean Louis

    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

    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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.