Hi,

I noticed that some Django public APIs use the % old-style string
formatting while others use the {} new-style formatting.

For example:

{} style

* success_url [0] (Converted to {} in 1.8)
* format_html [1]

% style

* ValidationError [2]
* related_name [3]


Is this difference intentional?

As success_url recently moved to {}, I'm guessing {} is Django's
preferred style?

If this different is not intentional, I would like to propose a change
to ValidationError to use the {} style formatting. This change would
go through the same deprecation path as used by success_url. Thoughts?

I think this would create a greater API consistency throughout the
framework. I think using a single, consistent string formatting API
follows the design philosophy "principle of least surprise".

Ultimately, I don't care what format is preferred, but I think one
should be used consistently.

I have created a proof of concept as to what this would mean as a
change. The change still requires new tests and docs; so it still WIP.

https://github.com/django/django/compare/master...jdufresne:remove-percent-placeholder

If there is support for this change, I would like to follow through a
ticket and finished PR.

Cheers,
Jon


[0] 
https://docs.djangoproject.com/en/1.9/ref/class-based-views/mixins-editing/#django.views.generic.edit.ModelFormMixin.success_url
[1] 
https://docs.djangoproject.com/en/1.9/ref/utils/#django.utils.html.format_html
[2] 
https://docs.djangoproject.com/en/1.9/ref/forms/validation/#raising-validationerror
[3] 
https://docs.djangoproject.com/en/1.9/topics/db/models/#be-careful-with-related-name

-- 
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 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/CADhq2b6RCWUhHFAAKsKeYbgpA35TQ%3DoQrHyR5vFL8UmTHn3QAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to