Fixes for generic foreign key raw id widget #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am porting a Django app to Django 1.11 and found some issues in the latest version of
django-authoritywhile doing so.The class
GenericForeignKeyRawIdWidgethasForeignKeyRawIdWidgetas a base class but its__init__method callsforms.TextInput.__init__(I am guessing that this is why its class name starts with the word "Generic"). The following PR is my attempt to address errors when attempting to view an individual permission from the permissions list view.The first commit on this branch addresses an issue that occurs when
renderis called on this widget. Duringrendera call is made toforms.TextInput.renderwhich then callsself.get_context. Unfortunately this goes toForeignKeyRawIdWidget.get_contextwhich then blows up as it the instance of the class is missing members that would have been added byForeignKeyRawIdWidget.__init__. In order to avoid this I have added aget_contextwhich simply delegates toforms.TextInput.get_context(resolves up; but it is calling into something that has been initialised).The second commit addresses an issue that occurs when clicking the anchor of class
related-lookupfrom the rendered widget. In the app that I am porting from Django 1.6.11, using django-authority 0.10 to Django 1.11 using the latest version of django-authority there are differences in the form of the URL where the widget is rendered. With the old version of Django and Django-Authority the path of the URL is like thisadmin/authority/permission/21852/where as with Django 1.11 and latest Django-Authority I am seeingadmin/authority/permission/21852/change/. Thus havingrelated_urlhard coded to"../../../"is not going to work for both paths. What I have done is past therequestobject into the widget so that it can work out how many../it should use to get back to the root of the "related" path.If you think this PR is off course or wrong could you please let me know :) thank you.