problems doing the Django tutorial on Dreamhost using Passengers - python

I have looked and I could not find this question before, and it surprises me.
I am reasonably proficient in Python, and I used Dreamhost for a number of years. Now I would like to learn Django. They are finally supporting it using Passenger. Which I do not know what is.
Following the instructions on Dreamhost I installed Django. Then I started following the tutorial 01. This went well, except that I could not start the server (this in the tutorial) since the code was live on dreamhost. At the time this did not seem to make any difference. Then when I went on the second part of the tutorial I had to access the admin site. And it worked well going to myurl/admin/ , as it should. But here the problems started. According to the tutorial (here) I have to add a file in the poll application and then restart the server. But I never started the server in the first place, my code is running live on the web... but when I add a file the website the admin acts as if it does not see it.
Probably dreamhost has started its own server, and I don't know how to restart it. But I assume this is going to be a common problem when you run django on dreamhost. Every time you add a file you will have to tell the server to consider it.
So what should I do to let the server know about it?
Thanks,
Pietro

Here's the relevant section of the Passenger user's guide for restarting Passenger:
http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application

Eventually I got the answer from the DH support service. They told me to
pkill python
I did it. I also checked with
ps -aux
what process I was running. And indeed I could see the python process starting when I went to the page, and being killed when I pkilled it.
Thanks for all that helped.

I had the same problem with Passenger not reloading the Django server.
According to Django wiki page on Dreamhost, you can touch a "restart.txt" file that Passenger watches. If the timestamp on the file changes, Passenger restarts Django.
If you modified your application and your changes do not seem to be reflected, you may need to notify Passenger about your change by creating or modifying ~/example.com/tmp/restart.txt:
touch /home/user/example.com/tmp/restart.txt
Source: http://wiki.dreamhost.com/Django#Hints

For the tutorial, you should be working on a local machine, not a web server.

Related

How to make a website work with Django development server?

I understand that this is never to be done. But I have a situation where I need to get something done real quick. I have to do a website where may be 200 people would register for an event. I need to present a simple registration form. Very basic functionality, register and view list of registrants. Very few hits. It would be live for about a month or so.
I know a little bit of Django which can allow me to put together this thing quickly. However, I have only worked with the Django development server.
My problem is setting up Apache to work with Django. I understand that, for Django, I need mod_wsgi installed. I have a VPS but mod_wsgi is not installed. I have asked my hosting provider to install it for me. Even if I can get mod_wsgi installed, it appears that it may take me some time to configure it and it may take a while.
I have the following questions.
Can I run this website on the Django development server? Will it hold up for very light traffic?
If I do, how do I get traffic to go from port 80 to the development server port. From the landing page, I can have the port number added to all the subsequent URLs.
I would also appreciate some guidance on getting Django to work with mod_wsgi.
Thanks
I use cloud9 for development. It is essentially a cloud ubuntu 14 virtual box, so it gives you a real url when django server is running (on port 80). Another use case of cloud 9 is for university classes, which is similar to your event use case. You can go there and setup your django project for free and people can find the page normally. But there are some restarts in your workspace that prevents it to be real server. If you pay 20 bucks per month they give you 2 premium workspaces that they assure that this does not happen ever. But I'm not sure if this is a good idea. I could not even imagine what kind of errors would you get if all 200 people chose to login at the same time, for example.
Another way to go is making a free amazon AWS account (or digital ocean) and doing your deploy there. AWS have 1 year free trial if you run only one microinstance with a particular setup which is plenty of time for your use case. I open the instance on AWS and SSH into it with cloud 9, so it feels like developing even in production. I'm far from a devops expert but I could deploy Nginx, gunicorn, django in AWS following this tutorial. You can do it too for sure, but is a lot of work.
Left my prefered choice for your use case to the end: pythonanywhere. It has free trial and it's really easy to setup. You follow some very basic steps (doing stuff with mod_wsgi that I still dont understand) and make it work in minutes. It's a whole business dedicated to serve python programs.
Hope this helps

Why does Python/Django keep redirecting to url 'catalog'?

I'm stepping into the Python world. First I learned a little Python. Then I learned the basics of Django, and on top of that I'm learning Wagtail (framework for template managing for Django)
To learn Django a went through a tutorial to build a site locally and test it in 127.0.0.1:8000.
At some point of the tutorial I configured the settings (because the tutorial said so) to redirect to 127.0.0.1:8000/catalog when browsing to 127.0.0.1:8000 alone.
Then I started the Wagtail tutorial, as a completely different project in another folder. Not sharing any code with the tutorial Django project.
I run the server and the console says it is now running in port 127.0.0.1:8000 and when I browse it, it redirects me to /catalog and of course shows a Page not found error since this project doesn't have one app catalog.
I workaround this by opening Chrome in Incognito Mode. But still I would like to know why this is happening and how to solve it to add to my knowledge of how Python works.
Some notes:
I'm on Windows
I killed all processes related to Python and actually this is still happening after turning my PC off and on
I know I could use a different port, please do not give me that answer. My goal is to learn.
Try clearing your browser cache.
The problem is most likely that your browser has cached a 301 Moved Permanently for 127.0.0.1:8000, thus never hit your development server when you enter the URL, but simply do the redirect based on the cache.
You will see the same result no matter what you're running behind port 8000, and it's as such not related to Django.

Installing django on dreamhost (help a newb out)

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

django one click deploy to dreamhost

I have a python/django application that im running on my dreamhost account. Excuse me for the novice question, but I'm a Java programmer by day and relatively new to python.
Ideally what I'd like to do is set something up where I can take the code I have locally, upload it to my server and then touch the restart.txt file. I realize I could probably accomplish this with a bat/ftp script, but I has hoping for something a bit more advanced/robust. I have a local mercurial repository where I'm doing version control, is it at all feasible to get mercurial running on dreamhost, and then set up so that when I push changes from my local repo to the server repo, those get deployed to the proper location?
Are there other solutions I should be looking at? I guess all I'm looking for is someone to point me in the right direction.
All the cool guys are using fabric nowadays. It's exactly what you looking for.

Django debugging with Eclipse and PyDev

I just managed to get debugging my django site 'kind of' working in Eclipse. All my breakpoints get caught just fine, but I have to restart the server every time I make a code change. I think this is because I'm using the --noreload argument when kicking off the server.
Is there any way to setup Eclipse debugging so that I can change code, and continue execution, with my changes being reflected in the django site straight away?
Cheers,
Dave
Trindaz on Fedang #django
This is a bit late, but in case someone else comes looking for a solution to the same problem:
This video was very helpful when I was trying to setup Django Eclipse debugging with autoreload i.e. without using the --noreload switch. It pretty much walks you through the steps with a couple of helpful pointers. I've set up twice myself using this video.
The manage.py replacement code can be obtained from http://djangosnippets.org/snippets/1561/
I found these links through the poster's blog post which seems to be down at the moment, hence the direct links
EDIT: A patch may be required to Django 1.3 to run in autoreload mode from inside an IDE. See PyCharm manage.py runserver error for more information.
http://bear330.wordpress.com/2007/10/30/how-to-debug-django-web-application-with-autoreload/
Author explains how to do so here, basically you have to embed the remote debugger into your manage.py file.
Hope this helps

Categories

Resources