Suggestion: add default "registration/login.html" to django.contrib.auth

147 views
Skip to first unread message

Ilya Kazakevich

unread,
Mar 3, 2015, 8:05:01 AM3/3/15
to django-d...@googlegroups.com
Hello,

When I use Django auth, I need to provide login.html myself. But Django encourages applications to have default templates which can be overwritten by user (via filesystem.Loader, for example). 
I suggest to provide default login.html with simple HTML form. User may always overwrite it.

Tino de Bruijn

unread,
Mar 3, 2015, 8:18:39 AM3/3/15
to django-d...@googlegroups.com
Yeah, or default to admin/login.html. The admin ships with all necessary "registration" templates, but for some reason only the login.html is included in the admin directory.

--
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.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9487d6c7-8ee2-4a64-aae6-9a05574c1464%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Graham

unread,
Mar 3, 2015, 8:36:52 AM3/3/15
to django-d...@googlegroups.com
The admin templates extend "admin/base_site.html" and rely on the presence of specific template blocks so I don't think it's appropriate for those dependencies to be added to contrib.auth. I'm curious to see what content you would propose for a default template. Typically I've seen login templates that extend from a project's base template so it inherits all the project specific styles, JavaScript, etc. I'm not sure a default template would actually be used much in practice.

Ilya Kazakevich

unread,
Mar 3, 2015, 9:22:17 AM3/3/15
to django-d...@googlegroups.com
I do not think admin templates should used. But something very simple and dumb (that looks similar to browser HTTP auth window). Here is example: http://pastebin.com/nnX36RB6
Css should be moved to static files, of course, to make this template cleaner and slightly more customizable. 

Imagine I need to create working solution as fast as I can. I really do not care about good UI now, because I need only a prototype to show it to my customer. I will not spent time creating nice login page: I just simply copy/paste template from Django documentation. And login page from contrib is great aid here. I will probably change login page UI later, but it is minor issue and priority is low. Many people in Intranet solutions (portals, CRMs and so on) are happy with browser HTTP auth window. They really do not care about how ugly is it.

Marc Tamlyn

unread,
Mar 3, 2015, 9:26:10 AM3/3/15
to django-d...@googlegroups.com
I can see the merit of including our documented example as an actual template as a starting point. It's unlikely to be used exactly as is very often but it reduces getting started friction for some users - "huh this view doesn't work, better go read the docs"

I'd perhaps be inclined to include it without styles even.

Marc

Ilya Kazakevich

unread,
Mar 3, 2015, 9:32:48 AM3/3/15
to django-d...@googlegroups.com
I agree: adding template from example is good idea! And I believe it will be used at least by newbies who just study Django auth system and by people who just need prototype. Providing default is better than copy/pasting example from docs.

Ilya Kazakevich

unread,
Mar 3, 2015, 11:27:26 AM3/3/15
to django-d...@googlegroups.com
So, should I create a ticket?

Aymeric Augustin

unread,
Mar 3, 2015, 1:16:49 PM3/3/15
to django-d...@googlegroups.com
I agree: providing a default login template would help. Getting started with contrib apps should be as easy as possible.

However the current proposal is backwards incompatible for users who define the login template in one of their apps that comes before django.contrib.auth in INSTALLED_APPS (if I remember the priority order correctly).

I don't think that prevents us from making the change but it should be pointed out in the release notes.

A more backwards-compatible alternative is to ship a default_login.html template and use select_template to fallback to that template when login.html isn't found.

-- 
Aymeric.

Marc Tamlyn

unread,
Mar 3, 2015, 2:08:13 PM3/3/15
to django-d...@googlegroups.com
I believe we standardised priority order such that earlier in the list always takes priority. Historically we had different orders for different things (templates, template tags, static files etc).

In any case, I don't think this should be a blocker and I'm in favour of including it as `registration/login.html`.


Aymeric Augustin

unread,
Mar 3, 2015, 3:12:05 PM3/3/15
to django-d...@googlegroups.com
You're correct, the first app has priority. Only management commands used to work the other way round. (Remind me who made that change?)

-- 
Aymeric.

Collin Anderson

unread,
Mar 4, 2015, 10:27:27 PM3/4/15
to django-d...@googlegroups.com
Could be as simple as: <form method="post">{% csrf_token %}{{ form }}<input type="submit" value="Login"></form>
Reply all
Reply to author
Forward
0 new messages