Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Arvind Nedumaran
No worries 

Sent from Outlook Mobile<https://aka.ms/blhgte>


From: django-developers@googlegroups.com  
on behalf of Florian Apolloner 
Sent: Tuesday, June 16, 2020 7:40:56 PM
To: Django developers (Contributions to Django itself) 

Subject: Re: Overriding template blocks without copy/pasting entire template 
files

Ah, might be that you got hold up in a moderation queue or similar. Google 
groups is weird sometimes -- sorry!

On Tuesday, June 16, 2020 at 3:20:25 PM UTC+2, Arvind Nedumaran wrote:
Something must be faulty with my email delivery I suppose. I sent that email a 
good 8 hours ago. :)

Onward,
Arvind

Sent from Outlook Mobile<https://aka.ms/blhgte>


From: django-d...@googlegroups.com  on behalf of 
Florian Apolloner 
Sent: Tuesday, June 16, 2020 6:46:45 PM
To: Django developers (Contributions to Django itself) 

Subject: Re: Overriding template blocks without copy/pasting entire template 
files

If you look at the mails beyond the first one, you will see that Josh & Carlton 
already came to that conlusion ;)

On Tuesday, June 16, 2020 at 2:16:31 PM UTC+2, Arvind Nedumaran wrote:
Could you elaborate on how this is different from extending a base template and 
re-defining the necessary blocks?

#base.html
{% block title %}{{ section.title }}{% endblock %}
.

{% extends "base.html" %}
{% block title %} My custom title that isn't section.title {% endblock %}


This much is already possible right?


On Tue, Jun 16, 2020 at 10:34 AM 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-d...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com?utm_medium=email_source=footer>.

--
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-d...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com?utm_medium=email_source=footer>.

--
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<mailto:django-developers+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/a357fb57-55b3-4f65-bf59-cf64c3e412bbo%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/a357fb57-55b3-4f65-bf59-cf64c3e412bbo%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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/BYAPR14MB291880739C1BB3E52F821C18A39D0%40BYAPR14MB2918.namprd14.prod.outlook.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Florian Apolloner
Ah, might be that you got hold up in a moderation queue or similar. Google 
groups is weird sometimes -- sorry!

On Tuesday, June 16, 2020 at 3:20:25 PM UTC+2, Arvind Nedumaran wrote:
>
> Something must be faulty with my email delivery I suppose. I sent that 
> email a good 8 hours ago. :) 
>
> Onward, 
> Arvind 
>
> Sent from Outlook Mobile <https://aka.ms/blhgte>
>
> --
> *From:* django-d...@googlegroups.com  <
> django-d...@googlegroups.com > on behalf of Florian 
> Apolloner >
> *Sent:* Tuesday, June 16, 2020 6:46:45 PM
> *To:* Django developers (Contributions to Django itself) <
> django-d...@googlegroups.com >
> *Subject:* Re: Overriding template blocks without copy/pasting entire 
> template files 
>  
> If you look at the mails beyond the first one, you will see that Josh & 
> Carlton already came to that conlusion ;)
>
> On Tuesday, June 16, 2020 at 2:16:31 PM UTC+2, Arvind Nedumaran wrote: 
>
> Could you elaborate on how this is different from extending a base 
> template and re-defining the necessary blocks? 
>
> #base.html
> {% block title %}{{ section.title }}{% endblock %}
> . 
>
> {% extends "base.html" %}{% block title %} My custom title that isn't 
> section.title {% endblock %}
> 
>
> This much is already possible right? 
>
>
> On Tue, Jun 16, 2020 at 10:34 AM 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-d...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> -- 
> 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-d...@googlegroups.com .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/a357fb57-55b3-4f65-bf59-cf64c3e412bbo%40googlegroups.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Arvind Nedumaran
Something must be faulty with my email delivery I suppose. I sent that email a 
good 8 hours ago. :)

Onward,
Arvind

Sent from Outlook Mobile<https://aka.ms/blhgte>


From: django-developers@googlegroups.com  
on behalf of Florian Apolloner 
Sent: Tuesday, June 16, 2020 6:46:45 PM
To: Django developers (Contributions to Django itself) 

Subject: Re: Overriding template blocks without copy/pasting entire template 
files

If you look at the mails beyond the first one, you will see that Josh & Carlton 
already came to that conlusion ;)

On Tuesday, June 16, 2020 at 2:16:31 PM UTC+2, Arvind Nedumaran wrote:
Could you elaborate on how this is different from extending a base template and 
re-defining the necessary blocks?

#base.html
{% block title %}{{ section.title }}{% endblock %}
.

{% extends "base.html" %}
{% block title %} My custom title that isn't section.title {% endblock %}


This much is already possible right?


On Tue, Jun 16, 2020 at 10:34 AM 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-d...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com?utm_medium=email_source=footer>.

--
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<mailto:django-developers+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com<https://groups.google.com/d/msgid/django-developers/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com?utm_medium=email_source=footer>.

-- 
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/BYAPR14MB2918A6E0935FE4DABCD96991A39D0%40BYAPR14MB2918.namprd14.prod.outlook.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Florian Apolloner
If you look at the mails beyond the first one, you will see that Josh & 
Carlton already came to that conlusion ;)

On Tuesday, June 16, 2020 at 2:16:31 PM UTC+2, Arvind Nedumaran wrote:
>
> Could you elaborate on how this is different from extending a base 
> template and re-defining the necessary blocks? 
>
> #base.html
> {% block title %}{{ section.title }}{% endblock %}
> . 
>
> {% extends "base.html" %}{% block title %} My custom title that isn't 
> section.title {% endblock %}
> 
>
> This much is already possible right? 
>
>
> On Tue, Jun 16, 2020 at 10:34 AM 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-d...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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/89b8d89a-d7e4-44fa-a5b8-cb8e1c910785o%40googlegroups.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Arvind Nedumaran
Could you elaborate on how this is different from extending a base template
and re-defining the necessary blocks?

#base.html
{% block title %}{{ section.title }}{% endblock %}
.

{% extends "base.html" %}{% block title %} My custom title that isn't
section.title {% endblock %}


This much is already possible right?


On Tue, Jun 16, 2020 at 10:34 AM 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/6cf43971-1ea9-4b93-9a35-aaab5908327co%40googlegroups.com
> 
> .
>

-- 
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/CAF_6RoMTbiq4S9qFBL1qU4B_KcJU%3DveP2%3D%2BMaT0%3D1Uxee%2BiEAQ%40mail.gmail.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Carlton Gibson
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 
)

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 
>> 
>>  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  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.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-16 Thread Josh Smeaton
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 
> 
>  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  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/95e2e0b8-f781-4274-b202-ce28f3571ee0o%40googlegroups.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-15 Thread Josh Smeaton
Changed 5 years ago 

 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  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/3ed867b6-0584-4e37-9099-1b60c1b412edo%40googlegroups.com.


Re: Overriding template blocks without copy/pasting entire template files

2020-06-15 Thread Carlton Gibson
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  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/e0fe802f-f673-471d-ac4d-8e4c613a0cf8o%40googlegroups.com.