I've just recently deployed my Django application using heroku, and have an issue where the profile pictures in my blog website don't save (ends up being an image that never loads).
Is there any way I can solve this (and if so, without using Amazon S3)?
I want to avoid Amazon S3 if possible.
Is there anyway or alternatives to implement images into my Heroku website?
I've used Cloudinary for a django blog on heroku. The api allows you to upload and display images quite easily.
You will have to serve the images using static files. Also, you will need to install WhiteNoise, which will serve the static files on Heroku. For the short-term this should be fine, however, for the long term, it is recommended that you use a cloud-based service.
This link is the main guide:
https://github.com/codingforentrepreneurs/Guides/blob/master/all/Heroku_Django_Deployment_Guide.md
I would recommend going through the references also.
These would be the references:
1) http://whitenoise.evans.io/en/stable/django.html
2) https://docs.djangoproject.com/en/3.0/howto/static-files/
3) https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#std:templatetag-static
I ran into the same problem you ran into. Following the steps in the guide and references worked well for me.
Related
I am trying to make a django application (with the Rest framework) and I was just researching and came across different ways to serve media files.
what is the recommended approach for a project/app that lets you upload pictures so that other users can download them?
I came across CDN such as uploadcare, cloudinary and then ofcourse amazon S3 as well. Is there a difference in using these services like uploadcare vs S3 in terms of speed or scaling?
thanks in advance,
Hello I recently deployed a django website on heroku and used aws to store my media and static files, the site was deployed successfully except i cant find the icons used by the template on production but those icons work locally what can i do to solve this. Thank you in anticipation of your favourable response
I try use dokku for my web projects - deployment become cool. But I can't find information about two things.
Can I autocreate database from dokku-util? How?
How and where store media files without using AWS? I want use only my vps'.
P.S. Or may be you see good materials about full workflow for dokku?
You can add plugins to dokku. Connect to your VPS, go to the /var/lib/dokku/plugins folder and then you can 'git clone' various plugins from github. There are a list of plugins on the dokku site that will create mysql, postgresql, redis, and other databases.
While the plugins work great, I prefer to run a second VPS that just hosts databases.
There isn't really a good way of serving static files directly from django--even when it's under docker. There is an app called dj-static that will help, but the author appears to be slow to update it for newer django releases. (https://github.com/kennethreitz/dj-static)
Currently porting some Django projects over to Google App Engine.
I am using Python 2.7, Django 1.4 and Google CloudSQL.
The problem I have is with an Admin driven Gallery.
Handling image upload seems to be a problem, using ImageField I am getting an erorr on mkdir command as GAE wont allow a local write.
I am a little stuck and solutions seem quite confused, I am using CloudSQL due to its compatibility with the old MySQL databases that ran the sites previously.
How can I get the gallery back up and running without local storage? I have been researching use of GAE blobstore, but posts seem quite varied and unhelpful.
Cheers
Kevin
You'll have to rewrite ImageField to use the BlobStore instead of files.
A quick google search suggests someone might have already done this:
http://blog.uysrc.com/2011/02/12/image-uploads-working-with-models-imagefield/
I'm about two months in with django. I've been following tutorials on youtube and such and one of the tutorials says that I have to use two servers when deploying my site. Django will be served from heroku and static files from amazon s3. I have to pay for two seperate servers to deploy a django app? I did not expect this and this would not be within my budget if this is so. Is he wrong or is this just for special cases like his? Any help would be appreciated
No, sounds like the video is a bit confusing. There is a distinction between static assets, ie the CSS/JS etc that makes up your site, and dynamic media, ie any user-uploaded content.
Heroku can quite happily serve static assets from the filesystem, and their docs on deploying Django state exactly how to do this. However you cannot store dynamically uploaded content on Heroku, since the filesystem is ephemeral. If your app allows this, you need to save them somewhere permanent such as S3.
Note however that S3 is really cheap; hosting media files there should only cost you pennies.
You don't need 2 different servers for deploying your django project. You can just use a single Amazon EC2 instance then install Nginx/Apache+Supervisor+Gunicorn+Python. After that, you just need to configure the location of your static files from your virtualhost. Here's a tutorial from digital ocean.