Yes! Absolutely. There's even a ticket for that: 
https://code.djangoproject.com/ticket/29336

There was a PR, but we couldn't get it down to size... (Review 
<https://github.com/django/django/pull/9884#issuecomment-527066452>)

On Tuesday, 16 June 2020 08:29:27 UTC+2, Josh Smeaton wrote:
>
> Upon reflection, would you agree that this should be documented a little 
> better? The release notes at the time had a vague deprecation note about `
> supports_recursion` being removed, and the main docs 
> https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#std:templatetag-extends
>  have 
> no such explanation about recursive inheritance either.
>
> I pointed out this thread to a few people in my team, and none of them 
> were aware of this fix/feature, and they were all using 3rd party packages 
> for support.
>
> Funnily enough, 
> https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#overriding-vs-replacing-an-admin-template
>  seems 
> to suggest this was always possible, so I'm quite confused.
>  
>
> On Tuesday, 16 June 2020 15:54:11 UTC+10, Josh Smeaton wrote:
>>
>> Changed 5 years ago 
>> <https://code.djangoproject.com/timeline?from=2015-04-22T17%3A28%3A19-05%3A00&precision=second>
>>  by Preston Timmons
>>
>> 🤦‍♀️
>>
>> Thanks Carlton - I guess it has *only* been 5 years though :)
>>
>> On Tuesday, 16 June 2020 15:41:29 UTC+10, Carlton Gibson wrote:
>>>
>>> Hi Josh. 
>>>
>>> This was added in Django 1.9 here 
>>> https://github.com/django/django/commit/fc2147152637e21bc73f991b50fa06254af02739
>>>
>>> It leverages the extends tag, re-using the same template name: 
>>>
>>>     # myapp/templates/admin/base.html
>>>     {% extends "admin/base.html" %}
>>>     {% block footer %}this site is restricted, blah blah legal text blah
>>> {% endblock %}
>>>
>>> So as long as myapp/templates are loaded before contrib.admin's then it 
>>> you should see the result you're after. 
>>>
>>> #15053 <https://code.djangoproject.com/ticket/15053> references 
>>> django-overextends as the influence. 
>>>
>>>
>>> Kind Regards,
>>>
>>> Carlton
>>>
>>>
>>>
>>> On Tuesday, 16 June 2020 07:03:53 UTC+2, Josh Smeaton wrote:
>>>>
>>>> Something that has bugged me for awhile is the requirement to copy and 
>>>> paste an entire template when you would just like to override a single 
>>>> block. This arises mostly when overriding admin templates, like 
>>>> `admin/base.html`.
>>>>
>>>> In my ideal world, I'd be able to do something like this:
>>>>
>>>>     # myapp/templates/admin/base.html
>>>>     {% override "admin/base.html" %}
>>>>     {% block footer %}this site is restricted, blah blah legal text 
>>>> blah{% endblock %}
>>>>
>>>>
>>>> And then the template loading system would find the next 
>>>> `admin/base.html` in the chain and use my overrides.
>>>>
>>>> There is prior art too. https://pypi.org/project/django-apptemplates/ 
>>>> allows you to override a template from a specific app using this syntax:
>>>>
>>>>     # myapp/templates/admin/base.html
>>>>     {% extends "admin:admin/base.html" %}
>>>>     {% block footer %}this site is restricted, blah blah legal text 
>>>> blah{% endblock %}
>>>>
>>>>
>>>> I think this kind of functionality should be included within Django 
>>>> itself. If others agree, should there be a new name such as override, or 
>>>> would overloading extends be good enough?
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/dc4c9fd5-206a-4734-95c7-3c7a2212c015o%40googlegroups.com.

Reply via email to