-
Notifications
You must be signed in to change notification settings - Fork 319
Media as a dynamic property #179
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
Conversation
**Symptoms:** While using AutoModelSelect2Field in admin site, I noticed that css files are rendered only at the first request to the add or edit forms, after that the widget is rendered but without loading any css files from get_select2_css_libs. **Solution:** I changed assets loading from [Assets as a static definition](https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property) to [Media as a dynamic property](https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property) as described at Django docs.
global name 'Media' is not defined
change get_select2_js_libs to get_select2_heavy_js_libs
|
I tested it with django1.7.8 and it works correctly |
|
Hi @razisayyed thanks for the contribution. Can you add a test for the problem you described? |
|
|
django_select2/widgets.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an instance of forms.Media with the right arguments rather then accessing private attribute on the instance.
|
@razisayyed this is legit, I checked it. Please review my comments and be so kind and add all information regarding you change in a docstring for the media property. |
Remove code that access private attributes of Media class.
|
@codingjoe please review |
|
|
|
|
1 similar comment
|
|
|
@razisayyed thanks! |
|
I think the root cause of that bug is that |
Symptoms:
While using AutoModelSelect2Field in admin site, I noticed that css files are rendered only at the first request to the add or edit forms, after that the widget is rendered but without loading any css files from get_select2_css_libs.
Solution:
I changed assets loading from Assets as a static definition to Media as a dynamic property as described at Django docs.