Django Project creation under the Windows Virtual Environment tool

Source: Internet
Author: User
Tags virtual environment

1. First switch to the previously installed Virtual Environment Tool catalog input Activate activation script, then enter the Python Interactive line command, import the Django module, view the version information, exit exit ().

G:\djangosite\env_mydjangosite\scripts>activate

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts>python
Python 3.6.4 (V3.6.4:d48eceb, Dec, 06:54:40) [MSC v.1900-bit (AMD64)]
On Win32
Type "Help", "copyright", "credits" or "license" for more information.
>>> django.get_verion ()
Traceback (most recent):
File "<stdin>", line 1, in <module>
Nameerror:name ' Django ' is not defined
>>> Import Django
>>> django.get_version ()

' 1.11.2 '
>>>exit ()

2, next installed in your virtual Environment command line, run the following command: Django-admin startproject mysite, the command will automatically create a mysite directory in your project directory, and all the necessary files, these are a basic, But the full-featured Django site. The following procedure and file structure diagram

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts>django-admin Startproject MySite

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts>dir

Directory of G:\djangosite\env_mydjangosite\Scripts

2017-12-28 16:43 <DIR>.
2017-12-28 16:43 <DIR>.
2017-12-28 13:38 2,195 Activate
2017-12-28 13:38 778 Activate.bat
2017-12-28 13:38 8,325 Activate.ps1
2017-12-28 13:38 1,137 activate_this.py
2017-12-28 13:38 508 Deactivate.bat
2017-12-28 13:58 98,213 Django-admin.exe
2017-12-28 13:58 159 django-admin.py
2017-12-28 13:38 98,180 Easy_install-3.6.exe
2017-12-28 13:38 98,180 Easy_install.exe
2017-12-28 16:43 <DIR> MySite
2017-12-28 13:38 98,152 Pip.exe
2017-12-28 13:38 98,152 Pip3.6.exe
2017-12-28 13:38 98,152 Pip3.exe
2017-12-28 13:37 100,504 Python.exe
2017-12-28 13:37 3,610,776 Python36.dll
2017-12-28 13:37 98,968 Pythonw.exe
2017-12-28 13:38 98,159 Wheel.exe
2017-12-28 13:58 <DIR> __pycache__
16 Files 4,510,538 bytes
4 Directories 7,875,833,856 bytes available

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts>dir MySite

Directory of G:\djangosite\env_mydjangosite\Scripts\mysite

2017-12-28 16:43 <DIR>.
2017-12-28 16:43 <DIR>.
2017-12-28 16:43 826 manage.py
2017-12-28 16:43 <DIR> MySite

(Env_mydjangosite) G:\DJANGOSITE\ENV_MYDJANGOSITE\SCRIPTS\MYSITE>CD MySite

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts\mysite\mysite>dir

Directory of G:\djangosite\env_mydjangosite\Scripts\mysite\mysite

2017-12-28 16:43 <DIR>.
2017-12-28 16:43 <DIR>.
2017-12-28 16:43 3,216 settings.py
2017-12-28 16:43 784 urls.py
2017-12-28 16:43 406 wsgi.py
2017-12-28 16:43 0 __init__.py

(Env_mydjangosite) G:\djangosite\env_mydjangosite\scripts\mysite\mysite>

3, the document interpretation refers to the original address of the translated text https://djangobook.com/installing-django/

These files are

1, external mysite/root directory. It's just a container for your project. its name is not important to Django; You can rename it to anything you like.

2, manage.py   A command-line utility that allows you to interact with a Django project in a variety of ways. You can read all the details about management.

The Command Line administration tool describes the original link address https://docs.djangoproject.com/en/1.11/ref/django-admin/

3, internal MySite/catalogue. It is the Python package for your project. It is the name of anything you use to import it internally (for example, Mysite.urls).

4, MySite/__init__. Py An empty file tells Python that this directory should be considered a python package. (if you are a beginner of python, refer to the package in the official Python documentation.) )

Package Description Original address Https://docs.python.org/3/tutorial/modules.html#packages

5, mysite/settings.py. Appendix D will show you how all the settings work.

6. Mysite/urls. py. The URL statement for this Django project; a directory of your Django power site. you can read more about URLs in chapters 2nd and 7th.

7, mysite/wsgi.py. an entry point for a WSGI-compatible Web server that serves your project. please refer to Chapter 13th for details.

Django Project creation under the Virtual Environment tool under Windows

Related Article

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.