A small guide here on how to setup Django 1.10.4 with Python 3.4.3 and MySQL 5.7 and Windows 10.
I decided to make this guide after I lost several hours trying to get Django to work with MySQL, this was a hassle! not so much that's complex to setup but rather to find the right wheel file that would work with these versions. And the graceful moment where you find out and finally got things to work :).
I use Python 3.4 as there does not seem to be a working mysqlclient build with Python 3.5 at the moment although I have an idea and will try this later (For a next guide).
So let's get started,
1. Download MySQL Installer for windows (here) and install MySQL
- After install, launch MySQL Workbench and create a new db schema and a db user with dbadmin rights
- Select "custom install" and select "add path environm. variables"
- Once installed check your version in a win command line with , "Python --version"
- Create a new Python virtual environment for your project
- "cd" to the "SCRIPTS" folder created in your freshly created virtual environment folder and activate it. You should now see the name of your venv folder between parantheses in the front) to deactivate the environment enter "deactivate.bat" from the same location.
3. Install Django
- Install django with command "pip install django"
- First fetch the mysqlclient file for your platform here, (I used the mysqlclient-1.3.6-cp34-none-win_amd64.whl file)
- Then in a win command line enter : pip install C:\PATH\TO\THE\DOWNLOADED\FILE
5. Now back to django, "cd" to your project directory and enter the following in a win command line
- "django-admin startproject YourProjectname", this will create a new django web-project
- Go into the folder project and edit the settings.py file and make the following modifications to the DATABASES section in it,
- Now ready to create the needed database tables for the Django project, Enter : "python manage.py migrate" and you should see the message displayed below.
Project ready to code :)