Forums

problem with synchronization my Mysql database and application

Hi, I have a problem with synchronization my Mysql database and application. When I run python manage.py syncdb I have a mistake:

ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.RequireDebugFalse': No module named RequireDebugFalse

I now that module MySQLdb –is a standart “battery” In a python shell all ok:

>>> import MySQLdb                                                                                                  
>>> MySQLdb.version_info                                                                                            
(1, 2, 4, 'final', 1)

A part of settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',     
        'NAME': 'archeology$default',                      
        'USER': 'archeology',
        'PASSWORD': 'my-pass',
        'HOST': 'mysql.server',               
        'PORT': '',                      
    }
}

Thanks P.S. sorry for my English)))

[edited by admin for readability]

Which version of Django did you create your application for? We have Django 1.3.7 installed by default, and I think that error normally happens when you have an app sett up for a later version.

It looks like you're using a virtualenv -- if so, and you haven't installed your preferred version of Django into the virtualenv yet, then you may be able to fix the problem by installing it.

How can i do this.

Something like this:

virtualenv env

source env/bin/activate

pip install django 1.5.1

or I have download and install this version of django

this variant is not work

13:36 ~ $ virtualenv env

New python executable in env/bin/python2.7

Not overwriting existing python script env/bin/python (you must use env/bin/python2.7)

Installing setuptools.............done.

Installing pip...............done.

13:37 ~ $ source env/bin/activate

(env)13:37 ~ $ pip install django 1.5.1

Requirement already satisfied (use --upgrade to upgrade): django in ./env/lib/python2.7/site-packages

Downloading/unpacking 1.5.1

Could not find any downloads that satisfy the requirement 1.5.1

No distributions at all found for 1.5.1

Storing complete log in /home/archeology/.pip/pip.log

(env)13:37 ~ $


In which directory must be placed a new version of Django?

You need to use pip install django==1.5.1 to install a specific version; putting a space between the package and the version makes pip interpret it as two different packages, one called django and one called 1.5.1.

In env I successful installed new version Django (1.5.1) (Thanks)))) but when I try to install MySQL-python I have a mistake:

EnvironmentError: mysql_config not found

Command python setup.py egg_info failed with error code 1 in /home/archeology/env/build/MySQL-python


when I try to install PIL

I have a mistake:

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

but in the directory: home > archeology > env > build

I see this 2 modules:

MySQL-python/

PIL/

Hi archeology!

We have a fix in place for this and I've patched live with it. However it is going to require me to kill all your processes and effectively "reboot" your account. Can you let me know, either via email (support@pythonanywhere.com) or here, when you are ready for me to do that? I should add that this won't change the contents of the account. Just the running processes.

It's a new account and I have all files on my PC You may to reboot my account.

Great, that's all done. If you enter your virtualenv again and run

pip install --upgrade mysql-python

It should successfully install this time.

The eagle eyed amongst you might notice that there is a c compiler (gcc 4.7) available now... This helps when you are trying to build cPython packages that require some compilation inside your virtualenv :)

Successfully installed PIL

Successfully installed mysql-python

Thanks )))))

AWESOME! Good work archeology.

I successful synchronizated Mysql database and application

and now I can get in the admin panel(http://archeology.pythonanywhere.com/admin/)

but when I try to see http://archeology.pythonanywhere.com/

I have a mistake: Server Error (500)


In archeology.pythonanywhere.com.error.log :

TemplateDoesNotExist: start.html

but this file (start.html) exists on the server

( / > home > archeology > mysite > mysite > templates > start.html)

P. S. I run” reload archeology.pythonanywhere.com"

on dev server ( on my local PC) all works

Check your TEMPLATE_DIRS entry in settings.py?

Thank you very much for your help))

I had a bug in TEMPLATE_DIRS

One more question:

How can I install the Django application, which does not have a standard set( in “ batteries “)?

I'm not sure I understand the question, but if you're talking about installng a new python package which isn't on our list of batteries included modules, take a look at the help text on the wiki, under "Useful python modules":

https://www.pythonanywhere.com/wiki

Thank you for your answer.

But now I have problem with my MySQL DataBase.

Content on my site in Ukrainian.

This content is entered via a form on the website and saved in a database (MySQL).

But when this content is displayed on the page from the database, it is not displayed normally

( like in this place:http://archeology.pythonanywhere.com/archaeologist/pub/7/ )

I think, it's a problem with the encoding (utf-8) in the database.

What can I do with this problem.

Something is certainly mangling the conversion... Where in your stack that is happening is not clear. You'll have to debug at what point it is destructively converted.

Whatever encoding you are uploading into your form you need to convert it to UTF-8 before you save it to the database.

Something is certainly mangling the conversion... Where in your stack that is happening is not clear. You'll have to debug at what point it is destructively converted.

Whatever encoding you are uploading into your form you need to convert it to UTF-8 before you save it to the database.

I looked, some system variables in MySQL (on your hosting) is not in utf8:

collation_database latin1_swedish_ci

collation_server latin1_swedish_ci

character_set_database latin1

character_set_server latin1


But in my project they are ( MySQL server on my local PC):

collation_database utf8_general_ci

collation_server utf8_general_ci

character_set_database utf8

character_set_server utf8


I tried to change this settings (in your console), but got the error:

mysql> SET GLOBAL collation_database=utf8_unicode_ci;

ERROR 1227 (42000): Access denied; you need the SUPER privilege for this operation

Do you help me in this question
P S My project only works with these settings (I checked) because I'm using not only the Latin alphabet

Swedish? that's weird. We've fixed it so that new databases will get the right setting.

If you want to change your existing database, just issue commands without the GLOBAL, eg:

SET character_set_database=utf8;
SHOW VARIABLES LIKE 'character%'; 
SHOW VARIABLES LIKE 'collation%';

not Swedish ------Ukrainian )))
(in Ukrainian language uses Cyrillic letters)

You have changed the settings but not all

I finished.

But the letters are all the same not normally displayed.

( http://archeology.pythonanywhere.com/archaeologist/pub/8/ )

Try to reboot my MySQL server, please.

Re the Swedish thing, I think Harry was confused that we had values like this:

collation_database latin1_swedish_ci
collation_server latin1_swedish_ci

...but I think that that is just because it's the MySQL default.

I also think that the commands he suggested above won't help. What I think you need to do is this (changing databasename to the name of your database, of course):

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_general_ci;

Then, for each of your tables:

ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

Try that, and let us know if it helps.

I read in the documentation that it is better to change the MySQL server settings before create the database

I deleted the old database

checked the MySQL settings

created a new database

successfully synchronized it with my project

Now when I go to the admin panel of the site - I see that the CSS settings do not work . (Http://archeology.pythonanywhere.com/admin/)

Nothing but the action with the database I did not do (the files have not changed)

The admin UI seems to be looking for its CSS files in /assets/, but in your static file configuration you have it set up to be served from /static/admin -- assets seems to be just your own CSS files.

I think you want to set ADMIN_MEDIA_PREFIX to /static/admin in your settings.py. You'll need to reload the web app to make it take effect.

now in settings.py

ADMIN_MEDIA_PREFIX ='/static/admin/'

but it did not work:

http://archeology.pythonanywhere.com/admin/

P.S. I reloaded the web app

ADMIN_MEDIA_PREFIX is deprecated in Django 1.5. You can probably create a static file entry for your web app that points from /assets/admin to the directory in your virtualenv that holds the admin media (the path would end with django/contrib/admin/media)

Unfortunately, I did not understand I have to do

Please, write pas items:

1 which files and where to move

2 and what to do with the string ADMIN_MEDIA_PREFIKS in the settings.py

thank you

On the web app page, you need to change the line that has the URL /static/admin/ so that it has the URL /assets/admin and the directory /home/archeology/env/lib/python2.7/site-packages/django/contrib/admin/static/admin

Glenn was correcting me in his last post; you don't need to change ADMIN_MEDIA_PREFIX.

now in the WEB page I have

/assets/admin/

home/archeology/env/lib/python2.7/site-packages/django/contrib/admin/static/admin/

but it did not work:

http://archeology.pythonanywhere.com/admin/ ( I reloaded the web app)

Now this is a test project

I ask you to change the settings

(Write what you changed later)

Now the main page gives a 500 error ---is normal

Help me to configure the CSS for admin panel.

I think it will be faster and easier for you and for me ))))))

thank you very much

It looks like you missed out the / at the start of the directory for the /assets/admin/. Try adding it, I'm sure that will fix it.

I tried your method - does not work (Several different variants)

your blog is written:

http://blog.pythonanywhere.com/60/

"Out of the box Django needs static files for the admin interface. If you visit www.yoursite.com/admin and it doesn't have any styling then this is the problem. Django looks for these static files at www.yoursite.com/static/admin."

"The url should be:/static/admin/"

I tried the method from the post

does not work

now in the "static file"

/ static / admin /

/ home/archeology/env/lib/python2.7/site-packages/django/contrib/admin/static/admin /

what should I change?

If I'm reading your post correctly, you were putting in extra spaces around the / characters, which won't help. Also, the "URL" field in the table needs to be /assets/admin like I said in my earlier post. /static/admin is what you would use if you were using Django 1.3, but you're using 1.5

I've updated your static file mappings so that they are what I suggested in my earlier post, and it looks like it works.

thank you very much for your help))

but I found another problem:

on my website

a user logs in and can download the pictures.

Then these pictures are visible on the site.

Pictures loaded successfully and saved in

home> archeology> mysite> mysite> media> media - it's right

but the pictures are not displayed

( http://archeology.pythonanywhere.com/archaeologist/obj/3/

at the bottom in the middle an empty border )

Since they successfully downloaded to the correct folder - I think, the way I've written correctly

It looks like you've missed the "/" from the start of the "Directory" section of your static files rule for /media/.

The URL should be:

/media/

And the Directory should be:

/home/archeology/mysite/mysite/media/

Right now, for the Directory, you just have

home/archeology/mysite/mysite/media/

and that's why it doesn't work. If you put a "/" at the start of the Directory and hit the Reload button, it will be fine.

Thank you))

No problem!