最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

GettingDjangoStartedonWindows7withPython3andMySQL_MySQL

来源:动视网 责编:小采 时间:2020-11-09 20:01:57
文档

GettingDjangoStartedonWindows7withPython3andMySQL_MySQL

GettingDjangoStartedonWindows7withPython3andMySQL_MySQL:pythonDjango bitsCN.com 07.03.2014|6 views|Related MicroZone ResourcesClustrix WhitepapersWhat We Offer: Clustrix FeaturesINFOGRAPHIC: The Future of the DatabaseProven in Production: Clustrix Case StudiesLike this piece Share it with your
推荐度:
导读GettingDjangoStartedonWindows7withPython3andMySQL_MySQL:pythonDjango bitsCN.com 07.03.2014|6 views|Related MicroZone ResourcesClustrix WhitepapersWhat We Offer: Clustrix FeaturesINFOGRAPHIC: The Future of the DatabaseProven in Production: Clustrix Case StudiesLike this piece Share it with your

pythonDjango

bitsCN.com 07.03.2014|6 views|

Related MicroZone Resources

Clustrix Whitepapers

What We Offer: Clustrix Features

INFOGRAPHIC: The Future of the Database

Proven in Production: Clustrix Case Studies

Like this piece? Share it with your friends:

|More

Django is a Python web framework library and it works on both Python 2 or 3. I will show you how to get python 3 set up in Cygwin environment.

If you're on a Windows OS, the best experience I have when working with Django on Windows is to use Cygwin, a Unix emulator shell that runs on Windows. The pip and django commands would automatically setup in Cygwin's PATH after installed. The default python package on Cygwin is only 2.7 though, so you have to search for "python3" package to get the latest python version. And you can have both versions installed without problem, but the executable are named "python" and "python3" respectively.

1. Install Cygwin python3 package. Verify "python3 -V" is working.

2. Install "pip" by downloading this "get-pip.py" file fromhttp://pip.readthedocs.org/en/latest/installing.htmland then run "python3 get-pip.py". Verify "pip3 --version" is working.

(NOTE: If you are running Windows 7, you might run into this issue:https://github.com/pypa/pip/issues/1448where pip exit without a warning. In this case the workaround is install Cygwin "binutils" and "libuuid-devel"packages, and that fixed the problem for me.)

3. Install "django" by running "pip3 install django"

4. Finally install the MySQL driver with "pip3 install mysql-connector-python --allow-external mysql-connector-python" command.

Now to get a django project started, try these:

django-admin.py startproject myapp

The "django-admin.py" script should automatically in your PATH. and this create a new project with initial settings. To switch default database from SQLite3 to MySQL, change the "myapp/settings.py" with the following:

DATABASES = {	'default': {	'NAME': 'mydb',	'ENGINE': 'mysql.connector.django',	'USER': 'root',	'PASSWORD': 'secret',	}}

Now I assume you have MySQL 5.6+ installed on your Windows already. Change the root password to match yours or using different DB user. You can now have django app setup the initial database schema tables for this specif myapp with this commad:

cd myapp
python3 manage.py syncdb

Follow the prompt and setup your admin user. Now you can start django web app:

python3 manage.py runserver

Open browser to http://localhost:8000/admin. Now try to login and enjoy!

  • https://www.python.org
  • http://cygwin.com
  • http://dev.mysql.com
  • https://docs.djangoproject.com
  • Published at DZone with permission ofZemian Deng, author and DZone MVB. (source)

    (Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

    Tags:
  • cygwin
  • django
  • Tips and Tricks
  • Python
  • Tools & Methods
  • bitsCN.com

    文档

    GettingDjangoStartedonWindows7withPython3andMySQL_MySQL

    GettingDjangoStartedonWindows7withPython3andMySQL_MySQL:pythonDjango bitsCN.com 07.03.2014|6 views|Related MicroZone ResourcesClustrix WhitepapersWhat We Offer: Clustrix FeaturesINFOGRAPHIC: The Future of the DatabaseProven in Production: Clustrix Case StudiesLike this piece Share it with your
    推荐度:
    标签: Windows windows7 and
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top