Tuesday, April 22, 2025

Django Dev Server


C:\my_projects>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
July 26, 2020 - 10:31:32
Django version 3.0.8, using settings 'my_projects.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

python manage.py runserver is a command in Django that starts the development server. When you run this command, Django will start a lightweight web server on your local machine, allowing you to view your Django project in a web browser.

The command python manage.py is used to interact with your Django project through the command line. runserver is a specific command that tells Django to start the development server.

Go to: http://127.0.0.1:8000/, you will see small rocket and message: The install worked successfully! Congratulations!

Go to: http://127.0.0.1:8000/admin/ to access Admin Panel, but you can't login because we didn't created admin credentials - yet.

Cancel server with Ctrl + Break, we need to create superuser - admin.

A superuser is a user account with all permissions to manage and modify the application. Superusers can access the admin site, which provides a graphical interface for managing the database and application settings.

We need to create a superuser during the initial setup of a Django application, so that we can have access to the admin site and perform administrative tasks such as creating and managing database objects, managing user accounts, etc. The superuser account also serves as a security measure, allowing only authorized users to perform such tasks.

But first - let's handle migrations:


C:\my_projects>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying sessions.0001_initial... OK

C:\my_projects>

Superuser - admin creation with ultra secure admin password: "admin"


C:\my_projects>python manage.py createsuperuser
Username (leave blank to use 'user'): admin
Email address: admin@server.com
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
This password is too common.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

C:\my_projects>

C:\my_projects>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
July 26, 2020 - 10:50:29
Django version 3.0.8, using settings 'my_projects.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

Now we can visit 127.0.0.1:8000 and we can login with our ultra secure admin-pass combination: 127.0.0.1:8000/admin

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...