- 1.django-admin.py Startproject MySite
- Start a project that initializes some project's structure files
- 2.python manage.py Runserver Ip:port
- such as: Python manage.py runserver 127.0.0.1:8080
- Use IP to access databases that are not on the same host
- 3.python manage.py syncdb
- Note: All of the Install_apps under configuration under setting.py are created
- App, create its corresponding data table to the specified database, but only create
- Tables that do not exist
- 4.python manage.py Startapp Polls
- To open an app called polls, create the following file:
- polls/
- __init__.py
- models.py
- tests.py
- view.py
- 5.python manage.py SQL Polls
- The SQL statement that creates the polls module is printed out, but this is not created in the database
- Corresponding table, to create the corresponding table, you need to first configure the Install_apps in the
- Specify the app, and then run the Synchronize database command: Python manage.py syncdb
- 6.python manage.py Validate
- Detect errors in the module
- 7.python manage.py sqlclear Polls
- A way to print out a data sheet that clearly blocks polls
- 8.python manage.py sqlindexes Polls
- Print out the index created in module polls
- 9.python manage.py Sqlall Polls
- Print out all the SQL statements that create the module polls, including the index
- 10. You need to write the __unicode__ () method in the module instead of the __str__ () method
- Because the __str__ () method calls the __unicode__ () method, and __str__ ()
- method returns a Utf-8 string, whereas the __unicode__ () method returns the Unicode
- string because all the data that is isolated from the database is converted to Unicode code, which
- Sample, __unicode__ () similar to Unicode (p), converted to Unicode code, __STR__ ()
- Similar to encode (' Utf-8 '), converted to Utf-8
- 11. Create Super users
- manage.py createsuper--username=joe [email protected]
- 12. Setting up the Django time zone
- Modify the time_zone= ' Asia/shanghai ', and reboot will be OK.
- 13. Find the path to the installed module
- Python-c "
- Import Sys
- Sys.path = sys.path[1:]
- Import Django
- Print (django.__path__) "
- 14. View the settings that have been modified
- Python manage.py diffsettings
manage.py Use of Django Learning