Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UserCreationForm description in django

Tags:

django

I created my own user class according to: https://docs.djangoproject.com/en/1.7/topics/auth/customizing/

Having this user created I would like to change description of the creation form. For now it's "First, enter a username and password. Then, you'll be able to edit more user options.".

Here's a screenshot:

enter image description here

I checked all meta fields and found how to change label of field but still can't figure out how to accomplish change of form description.

like image 752
gaculek Avatar asked Feb 22 '15 15:02

gaculek


People also ask

How do I create a Django username and password?

from django.contrib.auth import authenticate, login def my_view(request): username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) # Redirect to a success page. ... else: # Return an 'invalid ...


2 Answers

That's not in the form at all, it's just in a template:

https://github.com/django/django/blob/master/django/contrib/admin/templates/admin/auth/user/add_form.html

like image 190
Daniel Roseman Avatar answered Nov 13 '22 04:11

Daniel Roseman


Extension of Daniel answer:

The Django template engine has a defined order for loading templates. When it loads a template, it uses the first template that matches the name. You can override admin templates by using the same directory structure and file names.

You can add a custom admin template in the next steps:

  • Add template in the root of your project enter image description here
  • Include the templates (settings.py) enter image description here

Enjoy :)

like image 20
Yaroslav Draha Avatar answered Nov 13 '22 04:11

Yaroslav Draha