0
Opa, I’m using djando admin for login, by Accounts, and I’m using the User extended to two different tables, Business and User, and I’m doing fully signed up for user.negocio and user.usuario. So far so good, but when I log into the system I have a menu that I use via Inlcude and in it appear some user data, name, photo and more. In the code below I show how I tried the logic of for user.negocio show data of the respective user if it is user.user the same. But what I noticed is that {% if user.is_authenticated %} is validating and only it, because if I put in the first if user.usuario.name and user.negocio.name and then with user, it shows the name, even if it is within the user’s if.negocio And I’m not using any views for the.html menu. And if I take Elif and let it show in the menu both names and photos, when soon with user appear their data and when soon with business tbm, I think the problem is in Elif
html menu.
{% if user.is_authenticated %}
{% if user.negocio %}
{{user.negocio.empresa}}
<img src="{{ user.negocio.foto.thumbnail.url}}">
{% elif user.usuario %}
{{user.usuario.nome}}
<img src="{{ user.usuario.foto.thumbnail.url}}" >
{% endif %}
{% else %}
<form class="form-inline">
<a class="btn btn-primary btn-sm" href="{% url 'login' %}"> Entrar </a>
</div>
</form>
{% endif %}
Hello friend, yes user can be both user, as business, I am at work now, but half day I will try this your code, the last one sent, I am very new, as I use the context?
– Mauricio Kalfelz
and you are right both User and Business inherit from User, and the two are deferent tables I want to use both in the menu, if the user.user log in the data, as if log in user.negocio their data in the menu and even I want to use this system in the profile part meusite.com.br/profile shows user.user or user.negocio all within a profile.html only
– Mauricio Kalfelz
Context is like variables that are passed from the view to the template, a Python dictionary. You would have to go through the view or you can create a Processor context to be passed in all views. I suppose you start at first to understand the flow
– Allan Nozomu Fukasawa
I will try to assemble this context in my view, as it is passed to menu.html and this is include within all pages, I believe doing just for it serveria right
– Mauricio Kalfelz
You can use Session too
– Allan Nozomu Fukasawa
and how to pass these two context skin view options?
– Mauricio Kalfelz