Templates in Django

24 views
Skip to first unread message

אורי

unread,
May 14, 2020, 10:53:51 PM5/14/20
to django...@googlegroups.com
Hi,

I noticed that an app's template can't extend a template with exactly the same path in another app. Recently I had a need to extend such a template, called 'accounts/edit_profile/base.html', so I renamed it to 'accounts/edit_profile/core_base.html' and added a new template 'accounts/edit_profile/base.html' which only contains one line:

{% extends 'accounts/edit_profile/core_base.html' %}

And then, in the other app, I extend the same template with my changes:

{% extends 'accounts/edit_profile/core_base.html' %}

{% load core_tags_and_filters %}
{% load i18n %}

{% block edit_profile_links_1 %}
{% if request.user.profile.is_active %}
<my html code>
    {% endif %}
{% endblock %}

Is this the correct way to do this? Or is there a better way to extend templates?

Thanks,
Uri.
Reply all
Reply to author
Forward
0 new messages