reading-note

https://eng-ehabsaleh.github.io/reading-note/

View on GitHub

Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

specification

why Django

Comands & Results:

 django-admin startproject mysite

tree

mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py
 python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

November 04, 2021 - 15:50:53
Django version 3.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

If you want to change the server’s port, pass it as a command-line argument

python manage.py runserver 8080
python manage.py runserver 0:8000
python manage.py startapp polls
polls/
    __init__.py
    admin.py
    apps.py
    migrations/
        __init__.py
    models.py
    tests.py
    views.py

_ so we need to create the tables in the database before we can use them. To do that, run the following command:_

python manage.py migrate

To invoke the Python shell, use this command:

python manage.py shell

Creating an admin user

python manage.py createsuperuser
Username: admin
Email address: admin@example.com
Password: **********
Password (again): *********
Superuser created successfully.
python manage.py runserver

Django