OpenCiviWiki
OpenCiviWiki copied to clipboard
Fix setup
Closes #1206
Description
Fixes the various Mark-up errors caused while updating from backbone templates.
@gorkemarslan Can you help me with a problem? I understand the view function passes data to our static html, but I don't understand how we can access the user model from django's template syntax. Is it fine if I pass extra detail to the frontend by adding the data related to followers, Issues and Civis?
@AbhijithGanesh, in Django projects, user models are passed to the template with the context processors
:
https://github.com/CiviWiki/OpenCiviWiki/blob/9a9f82fe0834e06d78f5d9ec0ee430d3b28f9749/project/core/settings.py#L82-L87
so "django.contrib.auth.context_processors.auth"
is responsible for this action.
You can access a user instance in the template via {{ user }}
. If you want to get profile image URL, you should use
{{ user.profile.profile_image_url }}
in the template.
However, apart from the user model, you have to explicitly pass a model (Thread, Civi, etc) to the context
dictionary in the relevant view from the views.py
Could you explain more your purpose here? In which template you want to access these models?
Is it fine if I pass extra detail to the frontend by adding the data related to followers, Issues and Civis?
If want to access civis of a user you can use in the templates:
{% for civi in user.civis %}
<h2>{{ civi.title }}</h2>
{% endfor %}
Remember that there is one-to-many relation with the User model and the Civi model so we can access civis by user.civis
https://github.com/CiviWiki/OpenCiviWiki/blob/9a9f82fe0834e06d78f5d9ec0ee430d3b28f9749/project/threads/models.py#L186-L194
I hope I could help. If not, could you explain your purpose and your problem a bit more?