Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

740
Views
how to configure django with mysql using pymysql (python 3.5)

having much trouble getting mysql(5.6) to connect with django (1.11) using python 3.5.2 in ubuntu(16.04) venv. im trying to use pymysql because it works great with flask applications, just not django yet. mysqlclient failed install and has other dependencies (ive read django docs yes) so would prefer avoiding that module. this really should work since it works flawless in flask and others seem to have it working. heres what Ive tried and found:

# first steps

pip install pymysql

mysql -u root -p
CREATE DATABASE djang0 CHARACTER SET utf8 COLLATE utf8_bin;


# manage.py

try:
    import pymysql
    pymysql.install_as_MySQLdb()
except ImportError:
    pass

# settings.py

DATABASES = { 
    'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'djang0',
        'USER': 'root',
        'PASSWORD': 'mypasswd',
        'HOST': '',
        'PORT': '3306',
    }
}


# current models.py Post class for blog

class Post(models.Model):
title = models.CharField(max_length=140)
body = models.TextField()
date = models.DateTimeField()
image = models.ImageField(upload_to='uploads', blank=True)


# error - full here https://dpaste.de/vtEH

[Thu Apr 27 18:58:00.010964 2017] [wsgi:error] [pid 22811:tid 3049028416] [remote 192.168.0.3:52267] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
[Thu Apr 27 18:58:00.010967 2017] [wsgi:error] [pid 22811:tid 3049028416] [remote 192.168.0.3:52267] Did you install mysqlclient or MySQL-python?
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

had to use dependency, pip install mysqlclient. boo

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!