settings.DEFAULT_CONTENT_TYPE incompatibility with admin

175 views
Skip to first unread message

Tim Graham

unread,
Jan 10, 2017, 1:15:24 PM1/10/17
to Django developers (Contributions to Django itself)
According to ticket #23908 [0],

By using the setting:

DEFAULT_CONTENT_TYPE = "application/xhtml+xml"


The admin site no longer renders correctly.


Do you think we should try to fix this by having all the admin responses specify content_type="text/html"? That requires a lot of changes [1] -- I'm not sure if discouraging the use of that setting might be acceptable instead. I imagine any third-party app that provides templates has this same problem.


[0] https://code.djangoproject.com/ticket/23908

[1] https://github.com/django/django/pull/7807

Adam Johnson

unread,
Jan 12, 2017, 5:54:21 AM1/12/17
to django-d...@googlegroups.com
Having reviewed the ticket a bit and thought about it, I've had two thoughts:
  1. The current patch doesn't fix existing custom views which the docs explain how to use, and I've seen used quite often. It's quite likely custom views just return TemplateResponses.
  2. We could fix this instead by making the admin 'incompatible' with DEFAULT_CONTENT_TYPE being set to anything other than text/html with a system check to warn against / enforce this. This is possible because admin is a contrib app rather than part of django core. But perhaps the end result is probably similar to deprecating it, since many (most?) projects use the admin.
  3. This is actually the first time I heard about DEFAULT_CONTENT_TYPE and I think it's quite surprising that it's a setting and can affect all installed apps like this. After all, if a project is sending a lot of e.g. XML responses, it's possible, and probably clearer, to do similar to this PR and subclass TemplateResponse to set a new default for content_type.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7dd3a2df-5cfb-4eec-b949-7147cb5bdf24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

Marc Tamlyn

unread,
Jan 12, 2017, 5:56:49 AM1/12/17
to django-d...@googlegroups.com
DEFAULT_CONTENT_TYPE does sound like a setting which shouldn't exist.

Florian Apolloner

unread,
Jan 12, 2017, 8:11:09 AM1/12/17
to Django developers (Contributions to Django itself)


On Thursday, January 12, 2017 at 11:56:49 AM UTC+1, Marc Tamlyn wrote:
DEFAULT_CONTENT_TYPE does sound like a setting which shouldn't exist.

+1

charettes

unread,
Jan 12, 2017, 10:10:51 PM1/12/17
to Django developers (Contributions to Django itself)
+1

Aymeric Augustin

unread,
Jan 13, 2017, 3:22:13 AM1/13/17
to django-d...@googlegroups.com
Hello,

I agree that this setting has become less useful now that <!DOCTYPE html> has won.

It made more sense when it wasn’t clear whether XHTML1.1 would take over HTML4.

I’d be interested to hear about use cases, if someone still uses it and reads this.

-- 
Aymeric.


--
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-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.

Brian May

unread,
Feb 12, 2017, 7:13:01 AM2/12/17
to Django developers (Contributions to Django itself)
On Friday, 13 January 2017 19:22:13 UTC+11, Aymeric Augustin wrote:
I agree that this setting has become less useful now that <!DOCTYPE html> has won.

It made more sense when it wasn’t clear whether XHTML1.1 would take over HTML4.

I’d be interested to hear about use cases, if someone still uses it and reads this.

Sorry for delay in responding.

If you depreciate `DEFAULT_CONTENT_TYPE` I am not sure what you plan to do instead? Would Django hard code "text/html" as the default?

I hadn't realised that the XHTML standards are basically dead (and doesn't appear to be supported in HTML5), in which case this probably makes sense.

Thanks 

Adam Johnson

unread,
Feb 12, 2017, 6:14:24 PM2/12/17
to django-d...@googlegroups.com
Would Django hard code "text/html" as the default?

Yes, that's exactly what would happen.

Thanks for the bump up, finally added a ticket: https://code.djangoproject.com/ticket/27829

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam
Reply all
Reply to author
Forward
0 new messages