Forums

django admin page error

Hello, I have been following the youtube tutorial Python from Scratch-Creating a Dynamic Website, which is excellent by the way, and I am using the files on PA, not my computer. I managed to get things set up and running like the video until it came to accessing the admin panel. I uncommented the following from the settings.py file:

'django.contrib.admin',  
'django.contrib.admindocs',

as well as the following from urls.py:

from django.contrib import admin 
admin.autodiscover()
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),   
url(r'^admin/', include(admin.site.urls)),

I went to my bash shell, cd, then typed: python manage.py syncdb Things looked fine. I reloaded my webpage through PA and went to mysite.pythonanywhere.com/admin and received a host of errors including: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")

What am I missing? -Thanks

What version of Django does the tutorial want you to use? Our default versions are:

  • for Python 2: django 1.3 (this is getting a bit old now)
  • for Python 3: django 1.6

Harry, thank you for the reply. I am using Python 3, Django 1.6, which I believe is what the tutorial also uses. It does suggest running this at times, which I've also tried:

::: 
python2.7 manage.py syncdb

Either way, it seems to sync but throws the SQL error for the admin page.

Hmm, I'm not seeing the error when I go to your site's admin interface -- do you need to log in to see the error?

Hi giles, I had since deleted the web app I was using and was going to start over so now the admin page seems to be there. I'll post shortly if it happens when I get to that point again. The error was showing up without giving the admin login prompt. And as a side note, I do now have the login prompt but get an error after logging in, but I'm assuming that's because I'm starting that project over.

Ah, right. Makes sense. One thing to look out for -- the MySQL settings for Python 3 are a bit different to Python 2.7 (at least on PythonAnywhere), so it's possible that the tutorial you're following are specifying ones that don't work. Check out the section at the bottom of this help page