-
Notifications
You must be signed in to change notification settings - Fork 35
dbname not set at cursor create time #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you sure your requests reach the middleware? |
Thank you for your reply.
I guess it doesn't go to the middleware but I added the middleware as the first one in the middleware section. The following is the middleware section:
The following also is the database:
Please advise what would be the issue.. Thanks alot @stephane |
How do you access your application (hostname)? |
Thank you for replying Stephane and please help me because I can't access
it yet. I just try to run "runserver" just to open the server and I get
that error so I can't even make it work to start accessing it from the
browser. I also added a fixed name for the database inside the mapper so
that I remove the possibility that the mapper would be the issue. But
apparently it doesn't even reach the mapper. What do you think I should do
to know the problem? My initial thought is that it can't even connect to
the default database however I already have other projects that can connect
without any issues so it's not MySQL connection.
…On 27 April 2017 at 12:28, Stéphane Raimbault ***@***.***> wrote:
How do you access your application (hostname)?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJlKQDxU41lE7igqQOnONL98KTUW6zlyks5r0G3PgaJpZM4M4h6a>
.
--
Neamat El Tazi
Assistant Professor,
Faculty of Computers and Information,
Cairo University, Egypt
Email: [email protected]
--
|
I have been tearing my hair out with this issue too... Adding print statements I can see that the DatabaseWrapper._cursor() method gets called several times at 'bootup', i.e. before any requests are sent, during which time the middleware is not even loaded (and so db_name is not set on thread_local, hence the exception). Edit: sorry, the above is incorrect. The db queries which run at boot up prior to any requests are If my understanding is correct:
I'm wondering if we should raise the Using django 1.9.5 |
I've solve this issue setting the |
I am also getting the same issue |
I created a fork which I'm using as a workaround: https://github.com/andyhasit/django-db-multitenant |
@andyhasit that means you want to fallback to the default DB when not set? |
@stephane Yes, and that's what my fork does. |
@andyhasit could you propose a PR against master, please? |
I solve this problem adding:
To the first MIDDLEWARE, as say the documentation: Don't forget add in settings.py at the end file :
|
I followed all the steps that you mentioned in your docs but I always get the same error "dbname not set at cursor create time" when I run the project. I even sent a static database name inside the mapper just to try it and it returned the same error. It looks like it cannot initiate with the default database that I already added inside the settings. Any suggestions?
The text was updated successfully, but these errors were encountered: