Use MySql with Django [pycharm project]

Django_python

I started learning python/Django a few weeks ago. I was able to set up the development environment with PyCharm in windows and hoping to integrate Docker later.

I'm a newbie to python and had to face many issues when integrating MySQL client connector to Django/PyCharm development environment. I thought it is worth mentioning the steps in this blog post.

In this project which I'm planning to continue, I used python 3.7, 8.0.11 MySQL Community Server and Django  2.2.4
https://github.com/h-hub/dev-lobby

Step 01

Install python. There are a few things to mention when installing python.

install python step 1
Firstly, run the set up as administrator since I'm hoping to install this in the c drive. Then launch the setup, click "Add Python 3.7 to PATH" and select "Customize installation"


python install step 2
Secondly, select optional features and click next

python install step 3
Thirdly, input the custom location (There will already be a location, but better to choose something like this to avoid future issues. )

Step 02

Create a Django project with pycharm. 

create_django_project

Step 02

Install Django 2.2.4 and mysqlclient 1.4.4 from pycharm or using pip from the terminal.

install_django_and_mysqlclient

Step 03

Run/Debug the project. Before that make sure you have correct python interpreter which is same as the project interpreter.

debug_run_django_project

Conclusion

It is easy to set up a Django project with pycharm. Make sure to install python properly and the current user has the proper permission because it could be a concern when installing modules to python. I had to face issues like that and I hope this will be helpful in your learning process.

References

https://docs.djangoproject.com/en/2.2/ref/databases/#id6
https://www.jetbrains.com/help/pycharm/creating-and-running-your-first-django-project.html

Comments