Django 2 - migrating to Mysql from sqlite issues

9 views
Skip to first unread message

Pedram Badakhchani

unread,
Mar 5, 2019, 1:32:17 PM3/5/19
to Django users
Hi All,

I have a problem with the source code provided on the associated git hub pages: https://github.com/PacktPublishing/Django-2-by-Example After downloading the source files, and setting up the chapter 1 example locally, using the default sqlite database  everything works as expected. However, changing the database to mysql the site breaks. This is the scenario:
DATABASES = {
   
'default': {
       
'ENGINE': 'django.db.backends.mysql',
       
'NAME': 'pedbad',
       
'USER': 'root',
       
'PASSWORD': 'root',
       
'HOST': 'localhost',
       
'PORT': '3306',
   
}
}



Changing the settings.py file to use mysql works fine, and the database is created, and the tables are all populated correctly. using createsuperuser also works and I am able to access the admin backend and create a post navigating to :
 http://127.0.0.1:8000/blog/ shows the post and the post title link is set to:
http://127.0.0.1:8000/blog/2019/1/31/test-post/ however, although this works fine with sqllite, on mysql the link take me to a 404 page: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/blog/2019/1/31/test-post/ Raised by: blog.views.post_detail No Post matches the given query. even though the blog post exists in the mysql table: table blog_post id - 1 title - Test Post slug - test-post body - content for test post publish - 2019-01-31 10:56:40.000000 created - 2019-01-31 10:56:59.674959 updated - 2019-01-31 10:56:59.674976 status - published author_id -  1 I would appreciate any advice on why this is happening when the database is switched to MySQl thank you Pedram
Reply all
Reply to author
Forward
0 new messages