-
Notifications
You must be signed in to change notification settings - Fork 191
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
Use of messages variable causes conflict in django messages framework #5
Comments
Not sure I understand the issue here: the |
We were customising the rosetta template to fit in with the look and feel of our website by putting it into the local project under templates/rosetta. Because rosetta uses "messages" as the variable name, the usual messages framework is unusable for any of the customised rosetta templates. We're now using a patched version of rosetta (changing "messages" to "rosetta_msgs") which allows rosetta and the django messaging framework to co-exist properly. The issue is simply the use of the variable name "messages" when integrating rosetta into websites that also make use of django messages to convey information back to users. Hope that makes the issue clearer. |
Okay, I hope you'll agree this isn't an issue with Rosetta then, and probably best taken care of in a fork. |
It seems more of a naming issue to me. The messages variable name is part of django. Would it not just be possible to use a variable such as rosetta_messages rather than conflicting with django? It's only used in two places and anyone who uses django messages and rosetta will get this issue. |
Anyone who uses Rosetta embedded into the global admin, you mean? Or am I missing something again? |
It can affect anyone just trying to use the messages framework in their site alongside rosetta that has been edited to fit in with their look and feel. Basically, the home() view in views.py puts locals() into the context. Djangos messages framework also uses the messages variable name. So when a project puts something like: {% if messages %} <ul class="messages"> {% for message in messages %} <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> {% endfor %} </ul> {% endif %} into a template like base.html, django messages spits out all of the rosetta languages stored in the messages variable onto the page. So the project must either copy the above code into every template where they might want to see messages appear (tedious for even a medium project) or patch rosetta to use a less general variable name. I've make a fork and applied some changes but am wondering if you have any specific tests for templates. If not I'll set up a test project and make sure it all works as expected before making a pull request. Thanks, Becky Lewis |
Hi,
we use the django messages framework to pass notices to pages in our website. Unfortunately rosetta uses the local variable messages (line 200 in views.py). Due to the variable being named "messages" and the variable being returned in the response context we've found that the messages framework gets trodden on.
Would it be possible to use a different name for this variable in views.py (and pofile.html)?
The text was updated successfully, but these errors were encountered: