Django study notes (1) create projects and applications

pip install virtualenv//install virtualenv module
virtualenv djangoweb //virtualenv creates a virtual environment named djangoweb
Scripts\activate //activates the current virtual environment


django-admin startproject djangodemo //creates a django project named djangodemo
python manage.py startapp helloapp/ /Create a Django App named helloapp


python manage.py runserver//Test the server to run the project Basic packages needed to


run : django, pytz


In Django, the project (project) is the large framework and container of the Django website. ) is a specific Web application that


is functions and complete specific matters, and is included in the Django project (project). There can be many apps in a project, just like a website can have


article system, forum system, background system, etc., each app can also be stripped out as an independent module component.




python manage.py startapp video //created a Django App named video


admin.py: used to set the powerful management background that comes with Django;
apps.py: declared this App information;
models.py: used to define data model (database table);
tests.py: for unit testing;
views.py: used to define the views of the App, that is, business functions.


python manage.py migrate //Create some default database tables, run the command, it will show that many tables will be instantiated and migrated to the database


python manage.py makemigrations//Detect data migration changes of all data models in the project
python manage.py makemigrations video //Detect the data migration changes of video in the project (app must be added to the app list to detect)




python manage.py createsuperuser //Create a superuser (you can use Django's powerful background functions to modify the data model management)
password at least 8 digits, not all numbers

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324829896&siteId=291194637