manage.py Use of Django Learning

Source: Internet
Author: User

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

manage.py Use of Django Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.