Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide relationships whose related_name='+' (trac #22015) #2263

Closed
wants to merge 1 commit into from
Closed

Hide relationships whose related_name='+' (trac #22015) #2263

wants to merge 1 commit into from

Conversation

motiejus
Copy link

If related_name of a ForeignKey/M2M relationship is '+', user explicitly asked Django to not create backwards relation. This should be taken into account when rendering admindocs.

accessor = rel.get_accessor_name()
# If related_name == '+', backwards relations are explicitly disabled.
if accessor == '+':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a relation is hidden if it ends with a '+'. Here rel has a is_hidden method that abstract this check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Updated.

If related_name of a ForeignKey/M2M relationship ends with '+' (in other
words, related model is hidden from the other side), user explicitly
asked Django to *not* create backwards relation. This should be taken
into account when rendering admindocs.
@timgraham
Copy link
Member

Could you please add a test?

@motiejus
Copy link
Author

I would love to, however, currently only some internal helpers are tested; there is nothing to hook onto what produces 'output'. If there were, I would definitely add a test. But in this case I don't feel adventurous enough to set up a full-blown test suite for this contrib application* and so left my patch testless (and I am not doing the "full" work).

[*]: if I depended more on admindocs, I would certainly do that.

@timgraham
Copy link
Member

Ok, I've left a comment on the ticket to that effect to see if anyone else is interested in adding tests. Will close this PR for now.

@timgraham timgraham closed this Feb 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants