R
Railway•15mo ago
MIGHTY_MIDHUN

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
Percy
Percy•15mo ago
Project ID: fd0bd18d-392d-4b0d-af5c-395356468583
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
fd0bd18d-392d-4b0d-af5c-395356468583
Brody
Brody•15mo ago
what version of python are you using locally and what version is railway using?
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
its python 3.10 in local i dont know if there is any specfic python version in railway
Brody
Brody•15mo ago
of course there is lol check the build table at the top of the build logs
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
No description
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
its python 3.8
Brody
Brody•15mo ago
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
{ "$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
Brody
Brody•15mo ago
please read this section of the docs https://nixpacks.com/docs/providers/python#setup
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
NIXPACKS_PYTHON_VERSION 3.10 i just need to add this environment variable ?
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
No description
Brody
Brody•15mo ago
yep if that's the method you'd like to use
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
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
Brody
Brody•15mo ago
are you using alll the same dependency versions locally and on railway?
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
yes. I have added the version in requirements.txt
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
No description
Brody
Brody•15mo ago
right but that doesnt mean you are using those versions locally
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
I have checked again the requirements. This issue with database started coming only when i implemented multi tenancy in django app
Brody
Brody•15mo ago
then this is just sounding like a code issue this issue wouldnt be exclusive to railway, please research this issue
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
but this error doesnt happen in both of my local systems but only in production.
Brody
Brody•15mo ago
unfortunately that doesn't rule out a code issue railway runs your code as is after all
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
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
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
Bro 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 ?
Brody
Brody•15mo ago
^
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
yea I have set like this and pushed my code. But didnt work
No description
Brody
Brody•15mo ago
please reference this working template https://github.com/railwayapp-templates/django
MIGHTY_MIDHUN
MIGHTY_MIDHUNOP•15mo ago
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
Brody
Brody•15mo ago
🥳🥳
Want results from more Discord servers?
Add your server