Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User unable to generate django test database

So I am working my way through the Django tutorial and am on part 5 about creating tests for the Django environment. When trying to run the python manage.py test polls I get the error returned

Got an error recreating the test database: (1044, "Access denied for user 'user'@'160.39.140.132' to database 'test_mywebsiteURL_django'")

Now my problem is that I am using the servers that I host some domains I own on through bluehost for their mysql and am limited by them to only creating databases beginning with my websites address. So essentially all of my databases have the form "mywebsiteurl_django" or something of that nature, which means I can't create a database named "test_mywebsiteURL_django" like django wants me to because Bluehost won't allow me to make databases beginning with any other name than my url. So my question is whether there is a work around for this, or if anyone knows the files I can edit to have django try and create a database titled something like "mywebsiteurl_django_test" because Bluehost would allow that.

like image 463
John Mathews Avatar asked Nov 13 '22 05:11

John Mathews


1 Answers

Read the docs: https://docs.djangoproject.com/en/1.3/topics/testing/#the-test-database

Apparently you need to add TEST_NAME to your DATABASES in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mywebsiteurl_django',
        'TEST_NAME': 'mywebsiteurl_django_test'
    }
}
like image 195
neko_ua Avatar answered Nov 15 '22 07:11

neko_ua