How to have a site hosted on Heroku with database being stored locally on my computer? - django

I am hosting a Django site on the Heroku. However, Heroku does not allow databases with over 10 000 records stored for free. Can I store my database locally on a computer I have direct access to and still host the site on Heroku?
It is possible to use external database in Heroku by adding configuration:
heroku config:add DATABASE_URL=mysql://user:pass#server:port/database_name
But the question is what to I write for server in this case?

This is possible, but you will have to open up some ports on your local computer. Please look into port fowarding if you are into this. You are even able to post your whole website on your computer.
Personally I wouldn't recommend doing this, because you computer could become more vulnerable and you have to rely on your own home network and computer speed. Scaling is not easy with this setup.
However, there is (some kind of) an alternative. Django uses SQLite as the default database. You are able to use SQLite on Heroku. Please note that SQLite is not build for websites that interact a lot with your database and you cannot push a new build as easily as you would normally do. You will have to export the database first and then rebuild it later as Heroku creates a fresh website each time it builds (and the new database entries will be gone with that).
In other words: I would recommend to just pay for an upgrade of the database or move to another hosting company. I am sorry.

Related

How to get users back after deploying Django App to Heroku [duplicate]

I want to deploy an application with sqlite3 as the database on Heroku. However, it seems to be that Heroku doesn't support applications with sqlite3 as the database. Is it true? Is there no way to deploy my sqlite3-backed application on Heroku?
PS: I have successfully deployed my application using PythonAnywhere, but would now like to know whether there's any possible way to deploy it using Heroku.
As Heroku's dynos don't have a filesystem that persists across deploys, a file-based database like SQLite3 isn't going to be suitable. It's a great DB for development/quick prototypes, though.
Heroku do have a Postgres offering however that will suit - with a free tier and a basic $9/month tier that are good for hobby/small projects. The biggest benefit over SQLite is that you get backups that you wouldn't get otherwise (plus all the other Postgres features).
There's a guide to updating your settings.py to use Postgres here: https://devcenter.heroku.com/articles/getting-started-with-django#django-settings
Heroku has a detailed article explaining "Why is SQLite a bad fit for running on Heroku" https://devcenter.heroku.com/articles/sqlite3

How to update package/dependencies on live django website?

I have created a django website which now I am looking to deploy through DigitalOcean, I have not uploaded it yet because I want to get a clear picture before actually starting.
My questions are,
How to I update the packages required for my website once I have deployed my website?
Eg: I am using CKEditor 6. In future, when CKEditor 7 arrives how do I update the package so that my
website uses the latest CKEditor without losing any data.
DigitalOcean deployment works with and without git right? So should I skip git, because I really do not
care about versioning my website. Simple update through FTP apps(WinSCP, Filezilla) will work for me.
Generally speaking remote server is no different from a local machine what stays in your bedroom. Yes, it doesn't have monitor, yes, it is a rack with a lot of wires and yes, it is usually far away from you, but afterall the logic is the same. Thus everything works almost the same way it does on your local computer. Yes, you will be able to update dependencies, yes you will be able to not use git. But the fact you may not use git, doesn't mean that you should not. Also you will have to think of another DB, proxy server and intermediary between such and django app.

How use Dokku with django?

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)

ecommerce django app on webfaction versus VPS/DS versus Cloud Servers like EC2

Firstly, some background - I have been mostly using VPS/DS and EC2 for the django apps I build for the past 3-4 years.
On webfaction, I have only been deploying "trivial" apps or "personal blog apps" using both django and wordpress.
My biggest hesitation about deploying anything serious (with large amount of sensitive personalised user data such as addresses and phone records or ecommerce related data or even accepting a Paypal related transaction) on webfaction is that it is a shared hosting environment.
I like webfaction a lot because they have made it really easy to deploy django apps without the need for me to spend some time doing system administration and installing my own packages (which I obviously need to do on a clean EC2 instance or a VPS/DS instance on linode for example).
The question is - is it very unsafe to use webfaction (since it is a shared hosting provider and I can actually list the other users' home directory by running "ls -la" after I ssh in) to run an ecommerce application or an application which has a lot of personalized, sensitive user data? I would appreciate specific technical examples which can help me better decide whether or not to run a "simple" (yes, I know the word simple is dangerously ambiguous/undefined) ecommerce app - which probably will use the paypal payment gateway on webfaction.
I can address the specific concerns you have listed:
While you may be able to see other user's files, it's because they haven't changed the permissions on their files. You can use standard linux file permissions to keep other users from reading or writing your files.
chmod 600 file
You will most likely be storing your information in a database hosted by webfaction. While it is a shared enironment, you do get your own database that is protected by a password and a username. In short, it has the same security in place that a database hosted on a VPS would have.
While you do have to take extra steps to ensure the other users on the system cannot gain access to your information, it is certainly possible to keep your site secure in webfaction's shared hosting environment.

Development server & production server

What is the right way to handle a production and development website on the same server? the development code shouldn't be available until it's used for production.
I'm using Apache and Django and VPS hosting.
What should I configure? Apache- so it will have a special prefix for development stuff, Django- and have some URL mangling in the urlconf, or just get another VPS for development?
Find an old computer and stick it in your basement. you really don't need tons of horsepower for a dev machine & should be able to do it for a couple hundred bucks.
The problem with developing on a production machine is that you could crash processes [apache?] with some 'not quite debugged yet' code and affect live services, even if you have configured separate subdomains or virtual hosts.
never never never develop live.
-sean
PS> another VPS is a workable solution if 'spare hardware' is not available. However you could have availability issues.