How to deploy Django without mod_wsgi - python

I'm relatively new to web development, but I have a couple years experience working with python, so I figured I would build my first production site using django.
I've spent the last few days learning the basics and building a test site running on my local machine. Today, I've been trying to deploy my site to production; however, I've hit a pretty large stumbling block.
The django documentation suggests using mod_wsgi for apache deployments. I followed the install instructions here, only to realize that I don't have access to make any changes to apache - I'm currently on a shared hosting plan.
Apparently, to perform the install, I would have to upgrade to a VPS plan, which costs a lot more.
Any advice for a new web developer trying to get a proof-of-concept web app together (preferably with feedback gathered from real users) on a budget?
I think I have two options:
Eat the cost on my current web hosting plan. Try to find a cheaper host that specializes in django hosting. I've been looking at the following (suggestions here would be wonderful):
Heroku
DigitalOcean
A2Hosting
Try some sort of manual deployment. Is this possible or has anybody ever made this work? I can't seem to find any resources about this.
I was able to install django on my web server and my site just seems like a collection of files at this point. Can I simply move this directory tree to my site using an ftp? And handle the database migration manually?
Can I just run django on my web server via ssh instead of from my local machine? Essentially just rebuild my site in production? I know this isn't a smart idea with a normal production site, but as a proof of concept, I don't mind some downtime if my code is buggy.
Thanks!

If you are just starting Heroku is probably perfect for you. It's super easy to set up, you don't have to handle the server configuration yourself and it has a free tier to do some tests until you are ready to go.
If you are OK with doing some more advanced server/service configuration, you can use Google Cloud, Azure or AWS. This last one has a one year free tier. If you go this route, I suggest using gunicorn/uwsgi + nginx instead of Apache mod_wsgi.

Related

How to distribute Django web app to users?

I am developing a Django app to run on every client computer separately. The question is, which technologies should I use to distribute such as docker, virtual machine etc.? How can I protect the Django app's code? How can I prevent to distribute without licenses?
I suggest you look into Heroku. They have a free plan too so you can test it without having to pay first. Their guide with django after you set up an app is good too. You will find everything in their documentation but if you get stuck, I recommend this video by Corey Schafer. Good luck
Edit: Heroku also supports Docker but I'm not too familiar with it. Might be useful to you

Proper way to build web app with Django on remote web server

I'm fairly new to Django so please excuse my ignorance.
I'm starting my first build of a web app on my remote web server. I am currently SSH'ing to the server and have started the Django project. I just launched the development server for the Django project, and it automatically serves at http://127.0.0.1:8000/.
My question is- what is the proper way to build a Django web app remotely on a server? Am I supposed to build the app on my computer and then transfer the project to my web server after it is complete? Or is there a way for me to access the development server without messing with the domains/ip addresses of the websites that are live on my web server?
Thanks!
This isn't really a Django specific question as the same basic methodology goes for any software development project.
Create different settings files for development and production. For Django this will involve setting the ALLOWED_HOSTS in your production settings as you mentioned as well as other settings. This checklist is helpful for this step. Use environment variables to hide secrets and set them in your development and production machines as appropriate.
Use a version control system such as git and push changes locally and then pull them onto your production server then run your Django server.
Do one better and setup a CI/CD pipeline to automate this
Yes, you're supposed to build working project on your computer :)
You probably cant efficiently write something good on the remote server.
Then you will probably create the git repository, for example on gitlab.
Then you will work on your computer building your project.
When you want to see it on the remote server, you will pull your project there.
It will be a little tricky for a first time to correctly deploy it, but it's not really that bad + there are a lot of good instructions out there, for ex:
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
I hope I correctly understood your question.

Deploying Django Application

So I am quite the beginner in the world of web development. I have been working on a django application, and now that my application is running pretty well I am staring into the face of the monster that is deployment, and wondering which direction to take.
My application is running Django 1.7 and Python 3.4. I want to use PostgreSQL with Postgis as my database. I was originally thinking of using Amazon AWS for deployment, using their Elastic Beanstalk PaaS service, although now I am wondering if something like Heroku may be better for me as a beginner to all of this. I need my application to scale easily, without me having to dive into too much configuration that I am very likely to mess up.
What I am wondering is which service would be best for a newcomer developer deploying an application running the platforms I mentioned above. Heroku seems like it is a bit easier to use than AWS, but I am concerned that the pricing with Heroku would ramp up more quickly than with AWS. How difficult would it be to initially deploy using one service and migrate to another as I become more familiar with the process of maintaining web applications and/or as my needs change?
Any recommendations or info to help me decide on a service to go with would be very much appreciated.
Can I plug the company I work for, PythonAnywhere? Making Python application deployment easy is pretty much what we're there for :-)
Postgres support (including PosGIS) is currently in beta, but is pretty solid -- if you sign up, just drop us a line and we can enable it for your account.
Deploying Django service using postgres at AWS is as easy as you use local server, AWS is easy and good to use, you just need to confgiure confuguration file of Postgres and server you install at AWS. go to this https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn if you are using Apache.

Hosting my Django site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Hi I'm looking for some advice I currently own a resseller package with Heart internet as I host a few personal websites. However I'm currently learning Django (The python Framework) and want to be able to host my own server.
I have been setting up virtual servers to play around with. Anyway to have SSH access you have to send in and ask them to open it for you, in the meantime of asking them if it was possible to install Django / set up SSH access i was advised that i can't use Django unless i purchase a Virtual machine even though Python is intalled on the server.
Surley i can install Django onto my server if i have SSH access? Has anyone else has a similair issue? Or can anyone advise me on what to do.. The last thing i was to do is spend more money with them.
Thanks.
It sounds like you're describing a shared hosting situation where you have SSH access but the webserver is preconfigured for you. You cannot practically install and serve Django on that machine, because you will not have access to the Apache or other webserver configuration. You could theoretically serve Django from a port other than the typical HTTP port, but this would be extremely irregular and your hosting company would not appreciate it.
You can deploy Django on Heroku: https://devcenter.heroku.com/articles/django . It is free to deploy for extremely low-volume applications or for development; cost scales linearly with capacity above that.
You can also use Google App Engine with a slightly older version of Django. Either of these options have official support from the respective vendors and so they are much better ideas than trying to work around a restriction set by your hosting provider.
Finally, you could pay for a virtual machine, in which you would have full access to the webserver configuration and could serve anything you like. Virtual machines are available from any number of companies at a wide range of price points. You could also develop a Django application without hosting it anywhere but your local machine for starters, and worry about hosting after your application is functional.
AWS :
Free tier available
great support(but for technical help you got to pay)
can use platform (PAAS) BeanStalk
can customize architecture in case you get a dedicated instance
great community of support
Custom domain
great documentation
can SSH
Most popular
Heroku:(Django)
Free to some extent
Can use only POSTgresql in free plan
git must
Good support
easy to start
custom domain
Can use bash in production(Not SSH).. cannot make direct changes in production. This is what makes your App stable. Any change/update goes through git.
code maintenance - good (deployment through git heroku commands only)
use AWS S3 to store static files
Temporary files are removed perodically
Once you scale that they start to bill, it is really costly.
Since this is a PAAS, you have got what you have got. It takes lots of efforts to customize(to some extent) the architecture of the APP.
Google App Engine:( Flask/Django project.)
Free to some extent
very easy to start(hello world app)
custom domain
code maintenance - good (automatic deployment)
Support is not available
Pythonanywhere:
Free to some extent
No custom domain in free plan
easy to use
Good support
Webfaction:(Django)
Not free.. (I think (minimal plan) costs 10 $ per month on shared hosting. )
SSH available
custom domain
Architecture customization.
Good support
I have really good experiences with pythonanywhere.com. It's also free for really small projects.
For me it seems to be just perfect for experimenting with django. Here is a short story how I switched from Google App Engine to pythonanywhere.com: Django unchained - python in the cloud
I was doing the virtual server thing for a while - then entered Heroku. An extremely easy (and in some cases completely free) way to deploy my django application.
I started where you are,in a shared hosting environment trying to make django work. I then taught myself a lot of server admin and server setup things - thereby moving to a dedicated virtual server setup.
Alas making Django work with apache and on a Centos box can be a pain - But Heroku made it all better. Easy app deployment and scalability. Heroku is a cloud application deployment service - it's all the benefits of a virtual server without the setup. It doesn't actually install on your server
Check out these two articles
https://devcenter.heroku.com/articles/django
http://rdegges.com/devops-django-part-4-choosing-heroku (There are some more to this article but they are very lengthy)
I had a new django app up on the internet in half the time. There is lots of cost estimations involved, which is why I would dive deep into the second article and it's various parts.
You can host Django on Amazon EC2. If you take advantage of their free tier you can do so free for one year in a micro instance (618Mb RAM, 30Gb filesystem). You get full control of the machine, including SSH access. There are a number of freely available images that already bundle Django including the BitNami Django Amazon Machine Image which is also available for free (disclaimer: I am one of the BitNami developers)

using dropbox as a server for my django app

I dont know if at all i make any sense, but this popped up in my mind. Can we use the 2gb free hosting of dropbox to put our django app over there and do some hacks to run our app?
No, it's not possible.
If you want to use dropbox as the hosting, you can put static pages, meaning just the html files with CSS and javascript because those files can be retrieved by doing a simple GET request.
Hosting a python code is not possible as it requires server side calculations & dropbox is just for saving files.
See the official wiki for the available hosts. https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
The point you need to understand is: can you run django without djagno installed? Can django be installed on a usb-drive? Dropbox is but a cloud storage service NOT cloud hosting service. To store you do not require RAM and processors while for hosting you do.
Hence the answer is NO. If you are okay with configuring apache etc. you can go for VPS. If not try some managed servers. If you dont want to spend much and are looking at free hosting solutions for django a few of them are:
kodingen.com
shellmix.com
http://0x2a-dc.com/index.php?name=shop&cat=6
http://www.heliohost.org/home/
http://bitnami.org/cloud
https://www.alwaysdata.com/
more data:
http://freedjangohosting.com/
http://djangohosting.com/
https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts
Yes its possible! PythonAnywhere.com offers that!
What pythonanywhere does is pretty simple. They integrate your dropbox account with their one. When you want to create a Django app, all you got to do is, direct the platform to store the app in your dropbox folder!
Now, you can open your Django app in your PC and edit it (wait for some time to sync)..restart the app, it works! I practically tried.
Tip: There are many cloud platforms which offer great services for free. Openshift, Heroku, Google App Engine are to name a few!
No, you can't use DropBox to serve a Django Website, as doing so requires Python code to be run, when DropBox is only for saving & serving files.
You can, however, find free hosting for your Django needs, among which:
Heroku, originally meant for Ruby hosting, but now allows you to do Python hosting. I didn't find it particularly easy to use with Django though.
ep.io, Python-specific hosting, but invite-only for the moment - it's possible to get an invite by sending an email, explaining your project & your needs though. Offers you free SSL on *.ep.io, which is pretty nice, and they've got great service.
Dotcloud, not platform specific, but my personal favorite. It's pretty easy to get started, and the CLI allows you to do a lot (but the downside is that you need it a lot too). If you're not afraid of CLI, it's great.
Being said its not possible from dropbox to do that you can use very simple cloud hosting as told ahead,
I might be late for answer but you can get free cloud hosting from Linux Fedora company called RedHat. Their cloud product is available for free which supports django hosting. I tried it my own
Openshift Free Cloud Hosting
In addition to what Thomas posted, some other options for free django hosting:
Amazon Compute Instance (free for one year, free sign up).
Google App Engine (free limits,django howto).
OpenShift (django howto).

Categories