This article is an article for showing how to create an admin or a super user account through a command execution in the command line. The execution itself is quite simple. It is possible to login to the Django Administraton Page after successfully creating an admin or a super user account using the suitable command in the command line.
But before that, there are several requirements in order to be able to create an admin or a super user account. Those requirements are in the following list :
1. First of all, there must be a specific virtual environment for python runtime execution. In order to create a python runtime execution environment as in a virtual mode, this is the exact command to achieve it :
user@hostname:~/python/django/todoproject$ virtualenv -p /usr/bin/python3.7 env Running virtualenv with interpreter /usr/bin/python3.7 Already using interpreter /usr/bin/python3.7 Using base prefix '/usr' New python executable in /home/user/python/django/todoproject/env/bin/python3.7 Also creating executable in /home/user/python/django/todoproject/env/bin/python Installing setuptools, pip, wheel... done. user@hostname:~/python/django/todoproject$
The following is the execution for activating the environment :
user@hostname:~/Downloads$ source /home/user/python/django/todoproject/env/bin/activate (env) user@hostname:~/Downloads$
2. The next step is for installing django package.
After successfully implement the above steps, just execute the following command :
(env) user@hostname:~/python/django/todoproject$ python manage.py createsuperuser You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): todoapp. Run 'python manage.py migrate' to apply them. Username (leave blank to use 'user'): Email address: firstname.lastname@example.org Password: Password (again): This password is too common. Bypass password validation and create user anyway? [y/N]: y Superuser created successfully. (env) user@hostname:~/python/django/todoproject$
3. Run the project or the application by typing the following command :
env) user@hostname:~/python/django/todoproject$ python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). March 16, 2020 - 05:47:13 Django version 2.2.6, using settings 'todoproject.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
4. Last but not least, try logging in by using the username and password in the previous step. Do it by accessing the URL address of the application as it exist in the above internal webserver running process. The address is http://127.0.0.1:8000 or just type ‘localhost:8000’. The following is the image display :
Just insert the associated value in the Username and Password textfield. If the login process is a success, the following image will appear :