1

Earlier i had a problem with my pyodbc module, that did not run my application on the apache server, running on my windows machine. I found to solve my problem of getting the django project to run on apache using this hint.

But now I am facing a bit of a different problem. The django application runs on apache but throws this error on the page.

ImproperlyConfigured at /auth/login/
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Just to be clear, this project runs perfectly when deployed through djangos inbuilt server. This is how my database connection looks like in the settings.py

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'myDbName',
        'USER': 'myusername',    
        'PASSWORD': '',
        'HOST': '',
        'OPTIONS' : {
            'driver': 'SQL Native Client',
            'dsn': 'test',
            'MARS_Connection': True,
        },
    },    
}

UPDATE:

I updated my code according to Django MSSQL Documentation, ran into a few problems and got it to work by updating my pywin32 And again this works on djangos inbuilt server and NOT APACHE giving me the same ImproperlyConfigured error

DATABASES = {
    'default': {
        'NAME': 'myDbName',
        'ENGINE': 'sqlserver_ado',
        'HOST': 'MYHOST',
        'USER': 'myusername',
        'PASSWORD': 'mypassword',
        'OPTIONS' : {
            'provider': 'SQLNCLI11', 
            'use_mars': False,
        },
    }
}

My system - Windows 7, Apache 2.2, python 2.7, django 1.4.2, pyodbc-3.0.6.win32-py2.7

Any hints or tips towards this is highly appriciated, i ahve been trying to get this project up and running for quite some time now.

Thanks alot

6
  • Is Apache running on the same machine with access to the same Python packages? Commented Dec 10, 2012 at 13:30
  • Yes, previously I have created demo django apps, that say "It worked! Congratulations on your first Django-powered page." and they ran perfectly using Apache. Commented Dec 10, 2012 at 13:54
  • Were you using a different database engine in those cases? Commented Dec 10, 2012 at 14:13
  • In one of them I used the "sqlite3" and the other I used the "sql_server.pyodbc". But now I am starting to have a funny feelings if its got something to do with versions, cuz this project was initially built on django 1.3 and I moved it to 1.4, changing the structure and everything, works fine on djangos inbuilt server, Wonder if something else that's missing in the settings.py Commented Dec 10, 2012 at 14:27
  • 1
    It would be great if you could post that as an answer to your own question and accept it so others can see how you solved your problem :) Commented Dec 10, 2012 at 19:31

2 Answers 2

1

If you are using a built-in backend, you should specify database engine as given below:

'ENGINE':'django.db.backends.mysql'

If you are not using a built-in backend you should specify a fully-qualified path (i.e. mypackage.backends.whatever) in the ENGINE setting. Information on defining database backend in given in django documentation here.

Update:
You can try using django-mssql for using sql-server with django and the clear documentation is available here in readthedocs.

Sign up to request clarification or add additional context in comments.

4 Comments

I am using a "sql-server" backend not mysql. Using 'ENGINE': 'sql_server.pyodbc', works when i run the project with djangos' inbuilt server.
@shabeer90 If you are not using a built-in backend, you should specify the exact location of the package which is to be used.
I'm not pretty much sure about it. You can try this question.
Tried using the link you sent me. Works fine while using djangos inbuilt server, BUT DOES NOT RUN ON APACHE :|
0

The answer to my question might be a bit wierdbut hey this is how i got things to work on my machine.

The main problem I had was that my DSN was not getting connected with the django project, in the steps I have mentioned below, its the last step that made the whole difference in making it work. Previously I had selected "With integrated Windows authentication" while creating my DSN, but surprisingly it worked when I was running it using djangos inbuilt server.

  • Open the app ODBC Data Source Administrator in Windows 7 (search ODBC from Start Menu).
  • Under System DSN tab, click the Add button.
  • Select SQL Server Native Client 10.0
  • Enter DSN your_dsn_name, description(optional), and the SQL Server to connect , click Next
  • Select option “With SQL Server authentication using a login ID and password entered by the user”.
  • Enter Login ID ('your_username’) and password ('your_password’). Click Next, Next and Finish.

And i changed my database connection back to the original code

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': 'MaDaMa_App',
        'USER': 'your_username',
        'PASSWORD': 'your_password',
        'HOST': 'MYHOST',
        'OPTIONS' : {
            'driver': 'SQL Native Client',
            'dsn': 'your_dsn_name',
            'MARS_Connection': True,
        },
    },
 }

Thanks to all who helped me solve this, and hope this is helpfull for someone out there.

Cheers

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.