Skip to content

Conversation

@razisayyed
Copy link
Contributor

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.

**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
fix
fix
fix
fix
change get_select2_js_libs to get_select2_heavy_js_libs
change _media to _get_media

I hope it is the final commit :)
@razisayyed
Copy link
Contributor Author

I tested it with django1.7.8 and it works correctly

@codingjoe codingjoe added the bug label Jun 16, 2015
@codingjoe
Copy link
Collaborator

Hi @razisayyed thanks for the contribution. Can you add a test for the problem you described?

@landscape-bot
Copy link

Code Health
Repository health decreased by 0.33% when pulling b410aea on razisayyed:razisayyed-patch-2 into 1d49045 on applegrew:master.

Copy link
Collaborator

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.

@codingjoe
Copy link
Collaborator

@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.

@codingjoe codingjoe self-assigned this Jun 18, 2015
Remove code that access private attributes of Media class.
@razisayyed
Copy link
Contributor Author

@codingjoe please review

@landscape-bot
Copy link

Code Health
Repository health increased by 0.36% when pulling f124954 on razisayyed:razisayyed-patch-2 into 1d49045 on applegrew:master.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.36% when pulling d71876e on razisayyed:razisayyed-patch-2 into 1d49045 on applegrew:master.

1 similar comment
@landscape-bot
Copy link

Code Health
Repository health increased by 0.36% when pulling d71876e on razisayyed:razisayyed-patch-2 into 1d49045 on applegrew:master.

@codingjoe codingjoe closed this in b576bcd Jun 19, 2015
@codingjoe
Copy link
Collaborator

@razisayyed thanks!

@magicjohnson
Copy link

I think the root cause of that bug is that get_select2_css_libs() returns generator instead of tuple/list
#171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants