First of all, thank you ahead of time for any help on this thread. I have been meaning to ask for help with this matter for a while now and thought it was about time I asked.
For the past 6 months I have been working for this company as the only developer (full stack developer). I am running the whole shebang here. Prior to this job I have been able to deploy webapps through UBUNTU on AWS with experience in Django, Nginx, Gunicorn and Angular. Nothing too advanced.
The problem is that for the past 6 months I have been testing and developing through a very tedious manner. I would write a little bit of code, I git add,git commit, git push, and then git pull on the server followed by manage.py collectstatic. At first I went with it but now I would like to test changes locally and I am not sure how to do that. The webapp is a Django, with AWS MySQL database.
From my personal experience, I was able to run and test my own apps just by a simple python manage.py runserver but that doesn't seem to be the case here.
Related
I'm a newbie and learning Heroku systems. I want to run this CMS on Heroku. I ran it many times on my machine and on others' servers. But I don't have servers all the time. I want to make it on Heroku for contestants.
As always I tried to follow the docs of this app. The requirements and setup part runs fine. But the database creation and other parts I couldn't cope up with. As a result, it shows an application error. The app also uses Postgres. But the commands given for ubuntu, I don't know how I can make them in Heroku.
If it sounds stupid question please pardon me. If I have to learn about something please give me some resources to learn.
Or It it is not possible to run this app with heroku, is there any SSH tunelling trick to just make the contestant part online with heroku Or is there any way to just tunnel my localhost to heroku web app domain? Thank You Very Much.
I'm currently learning Django and getting a decent grasp of it. I know you can start the server with python manage.py runserver. But then there is also heroku ps:scale web=1 followed by heroku open to open the web page at the subdomain you chose on the host herokuapp.com. What is the point of using heroku vs just runserver? When it comes time to deploy to production is that what heroku is used for as I read it was for deployment? What is exactly is heroku used for and what are the reasons? When creating a professional django web site/application is heroku required or just very useful? If so why? I don't really understand the reason for using heroku. And I'm curious what the best practices are for django and whether they include using or not using heroku.
Aside from the heroku question, what are the best practices for django as far as setting a domain name and such (other than the herokuapp.com subdomain name) and also as far as what other components/software solutions are worth using with django?
One of the things I'm working on is an FTP portal on the website that people can login to and upload files. Does django have plugins/python modules for such a thing or must it be done custom? Which brings me to my final question, What kind of addons/modules does django offer to avoid reinventing the wheel when implementing a django website/app's certain features?
The tutorial I'm following: http://tutorial.djangogirls.org/en/django_orm/README.html
has helped me get a grasp on django, but I'm curious about the more advanced parts of it. Such as custom modules, custom styling, custom scripts (whether they are js or strictly python).
If someone could point me in the right direction or offer any suggestions it would be much appreciated. The tutorial has me using the modules: dj-database-url, whitenoise, gunicorn, python-dateutil, psycopg2 , requests. I know what some of them do, but what is the purpose of psycopg2, whitenoise, dateutil, and dj-database,url? Are there any other modules worth using?
Sorry for the wall of questions, but I'm trying to understand django as best I can so that I can do a correct assessment when putting together a django project.
Thanks in advance.
EDIT, final questions:
1) Also when i used heroku they gave me a subdomain at herokuapps.com Can I set my own URL and still use heroku?
2) And last but not least, heroku makes you register and gives you a subdomain on herokuapp.com Is there a way to use heroku with your own domain rather than the one they give you? Is there a specific way to do it?
EDIT 2:
When I do runserver it works fine, but when i run it with heroku ps:scale web=1 and then heroku open it opens but only shows the title at the top of the page, and no content. Not sure exactly why that is. Can someone explain the difference between runserver and heroku ps:scale web=1 followed by heroku open??
python manage.py runserver is only for development. Never use it in production.
Heroku makes it super easy to deploy your Django code. You only need some configs and git push heroku master. But it's not the only way to deploy your code. You can also set up a server with a webserver like Nginx, Gunicorn as WSGI server, and a database of your choice. To set things up, you need to know something about Linux and the command line.
So if you don't know how to set up a server, Heroku can be very useful.
Heroku supports custom domains, and it's easy to set up.
As Mikeec3 mentioned, "Two Scoops of Django" is a very good read.
If you are looking for django packages, www.djangopackages.com is a good place to start.
psycopg2 is for postgresql usage with your app. White noise allows you to serve your staticfiles without nginx if using gunicorn. Requests is an easy to use urllib2 library with pythonic calls to work with apis from other websites.
If you want to do some testing with say facebook logins Heroku is a great place to go to, especially if you need a url outside of localhost.
My suggestion is you read Two scoops of Django http://twoscoopspress.org/products/two-scoops-of-django-1-6
It goes over alot of best practices and serves as a great tutorial after polls. I suggest also incorporating django-bower into your project. Ill list a few great things to add.
Django Bower: https://github.com/nvbn/django-bower - Helps organize static files
Crispy Forms : https://github.com/maraujop/django-crispy-forms - Great form rendering, great with bootstrap
Django Rest Framework: https://github.com/tomchristie/django-rest-framework - REST APIs
These are just to start, there's alot to learn.
I have a Django project with 1 app that is working locally and I am trying to make it work on the server but I imagine I am still missing something...
The steps I have followed are:
1) create a virtualnev
2) Install django and the libraries I need
3) copy my local project to the server, keeping the same directory structure
4) create the file passenger_wsgi.py (python passenger_wsgi.py did not return any error)
After this do I need to do anything like python manage.py runserver? Or with this I should be already able to see the site through mydomain/my project/ my app (when I do ot just get an error 404)?
I have read the django book and followed the tutorial, but this part is not well described anywhere...
Thanks in advance for any help!
Deployment is explained in the documentation.
You need to actually serve your application with some kind of HTTP server and something to run your python code. Some of the possible combinations are:
nginx with uWSGI
Any web server as reverse proxy with gunicorn
Apache with mod_wsgi
Your hosting service may or may not give you the choice or even the possibilty to do this.
There is a list of Django friendly hosters in the Django wiki.
Well firstly you might want to go through the previously asked questions.
When you are deploying using passenger you do not need to run manage.py runserver , etc. The passenger_wsgi file should take care of it.
You might want to check this link out, in the first answer also contains link to Dreamhost which details quite extensively on how to achieve the same.
Visit Deploying Django app using passenger
From my personal experience I found Nginx and uwsgi setup to be much more easier to handle and work and debug in the logs, but this is subjective to your needs and platform you may have.
I'm looking for a hosting service to run my python scripts. My python scripts take info from various API's and put them into a Mongo database. I'd like to schedule them so that they run once an hour. Right now I'm running python 2.6 and using a couple of extra packages like facebook sdk and python twitter tools. I've been looking into heroku, but I'm new to the service and I'm having trouble finding documentation on heroku and python. The other service that I came across is MongoHQ, but I'm unsure as to how that works with Python. Do you know of a hosting service that would be compatible with all of these things?
EDIT
I took the advice below and explored DotCloud a bit. For anybody who's a newb like I am, I wrote a post on it on my blog (swootsblog.cloudfoundry.com) which I hope is pretty easy to follow along with. It's a continuously running python script writing to a MongoDB all set up on DotCloud.
Heroku doesn't run Python, they only run Ruby, Node.js, Clojure and Java.
There might be other services, but I've played around with DotCloud which has a python worker type for exactly this sort of work.
Heroku Does runs python scripts, I have previously done this with python to postgres database,
Pre-req
pythonscripts.py
procfile
requirements.txt
and After add, commit and push the scripts to heroku app. Just run the following command on terminal to run the scripts.
heroku run python your_scripts.py
More if you want to run this scripts on a schedule timing. then heroku provides lots of adds-on. just search it on heroku
If you need more help, make a chat with me.
I'm trying to get django running on my dreahost account. I've been trying to sort of use two tutorials at once: the one on the dreamhost wiki and the one in the django book.
I installed django using the script on the wiki page, but I ran into trouble immediately while trying to work through the django book. It says:
To start the server, change into your project directory (cd mysite), if you haven’t already, and run this command:
python manage.py runserver
This launches the server locally, on port 8000, accessible only to connections from your own computer. Now that it’s running, visit 127.0.0.1:8000 with your Web browser. You’ll see a “Welcome to Django” page shaded in a pleasant pastel blue. It worked!
Those instructions seem to assume that you're developing locally, not on a shared server. Where the heck am I supposed to look for the "Welcome to Django" page after starting the server? In my webroot? No dice.
Anyway, I tried to blunder ahead through the django book to its hello world tutorial (chapter 3). But once I've edited the view file and the URLconf, I don't get a nice clean "hello world" text. Instead (as you can see) I get an "import error".
Any help would be greatly appreciated.
Don't try and learn Django via your server. Install it on your local computer, learn how it works, develop your project, and then install it on Dreamhost.
Your project assumes that 1) your app is called "mysite", and 2) mysite is a package, e.g. mysite/__init__.py exists. If either of those are false then correct your code and/or file structure.
This is an old post and am sure you have found the answer by now. I have solved this problem by using the command
python manage.py runserver mydomain.com:8080