WearBullish
How to save or access plt svg in volume using Django?
My Django app is working perfectly and I've already integrated volume in my repo, users can change their profile picture and display them through my app views.py.
It is setup like this.
settings.py:
STATIC_URL = '/static/'
MEDIA_URL = '/images/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'images')
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
app url:
urlpatterns += [ re_path(r'^static/images/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT})]
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
volume mount path:
/app/static/images
When a user uploads a new profile pic in my volume through my views, I can access it through database image in my html {{user.image.url}}
the path will be like this.
img src="/static/images/doctors/profilepic.png"
Now I have a separate python file called forecasting.py inside the doctors app and I don't know how to save the plt and its path without going through the database and accessing it through plt.url.
I tried:
plt.savefig(f'forecasting/Forecast{Dataset.columns[0]}.svg')
and access it through:
src="/static/images/doctors/forecasting/Forecast_Hepatitis%20A.svg"
but it's not working even if I modified the src to another path I'm aware of.
11 replies
Deployment via github taking more than 25 minutes
Usually when I push changes in my repo it will take 10 minutes max to deploy, now it's taking more than 25minutes after my latest push. Building is done in my build logs but deploying is not starting.
No deployment logs. All output sent to stdout will be displayed here
45 replies
Deployment Failed during build process
My django project cannot deploy, it stops at
#10 78.98 Getting requirements to build wheel: started
#10 79.36 Getting requirements to build wheel: finished with status 'error'
#10 79.37 error: subprocess-exited-with-error
See the attached file for the full error log
My railway.json
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"nixpacksPlan": {
"providers": ["python"],
"phases": {
"setup": {
"nixPkgs": ["...", "nodejs"]
}
}
},
"buildCommand": "npm ci"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn webapp.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
I have a customized railway.json because I have a package.json for full calendar, dropzone, and moment js.
runtime.txt:
python-3.10.10
10 replies