AttributeError: 'DatabaseWrapper' object has no attribute 'set_schema'
I'm using django with mutlitenants using the package django-tenants==3.5.0
When i deployed the app to railway im getting the error.
AttributeError: 'DatabaseWrapper' object has no attribute 'set_schema'
I have also updated the railway environment variables and set my engine to ... ENGINE=django_tenants.postgresql_backend
But I'm not able to fix the error
31 Replies
Project ID:
fd0bd18d-392d-4b0d-af5c-395356468583
fd0bd18d-392d-4b0d-af5c-395356468583
what version of python are you using locally and what version is railway using?
its python 3.10 in local
i dont know if there is any specfic python version in railway
of course there is lol
check the build table at the top of the build logs
its python 3.8
have railway uses 3.10 too
https://nixpacks.com/docs/providers/python#setup
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": [
"python"
],
"phases": {
"setup": {
"nixPkgs": [
"...",
"nodejs"
]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "pip install -r requirements.txt && python manage.py migrate && python manage.py collectstatic --noinput && gunicorn hospital_site.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
this is my railway.json so how to modify it
please read this section of the docs
https://nixpacks.com/docs/providers/python#setup
NIXPACKS_PYTHON_VERSION 3.10
i just need to add this environment variable ?
yep if that's the method you'd like to use
ok let me see this if this would fix the issue hopefully 🙂
im still getting the issue, I think the problem is not related to the python version. Could it be something else
are you using alll the same dependency versions locally and on railway?
yes. I have added the version in requirements.txt
right but that doesnt mean you are using those versions locally
I have checked again the requirements. This issue with database started coming only when i implemented multi tenancy in django app
then this is just sounding like a code issue
this issue wouldnt be exclusive to railway, please research this issue
but this error doesnt happen in both of my local systems but only in production.
unfortunately that doesn't rule out a code issue
railway runs your code as is after all
ENGINE=django_tenants.postgresql_backend
I have set my engine like this in my environment varibles. My doubt is that could there be a problem with setting engine like this in railway
normally you set
ENGINE
in your settings.py
https://github.com/vfehring/django-volumes/blob/master/mysite/settings.py#L84C10-L84C16Bro I'm still facing the issue 😢 from what i googled I cant find a solution for this. Usually this error happends when we are not using postgres. But my code looks fine and I have tried connecting with differnt dbs in local and it works fine. its crashing only in prod. Is there anything to do with the railway.json file ?
^
yea I have set like this and pushed my code. But didnt work
please reference this working template
https://github.com/railwayapp-templates/django
Thanks very much Brody you are literally god sent. I messed up the variables that I had set in the railway. It had nothing to do with the python version. Cheers thank you very much once again
🥳🥳