Django 404 errors

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

If you experience strange 404 errors with Django apps, read the following.

First, check the logs (either with "dotcloud logs", or with "dotcloud ssh" and then fiddle around).

Start with the nginx logs, in /var/log/nginx/.....error.log.
If you see the following:

[error] 62#0: *86 upstream prematurely closed connection while reading response header from upstream, 
client: 10.254.99.244, server: [...], request: "GET / HTTP/1.0", upstream: "uwsgi://unix:///var/dotcloud/uwsgi.sock:",
host: "[...].dotcloud.com", referrer: "[...]";
[error] 62#0: *86 open() "/home/dotcloud/current/static/502.html" failed (2: No such file or directory), 
client: [...], server: [...], request: "GET / HTTP/1.0", upstream: "uwsgi://unix:///var/dotcloud/uwsgi.sock:",
host: "[...].dotcloud.com", referrer: "[...]";

It means that the 404 error is actually a 502 error (but if no 502 error page is defined, it ends up with the 404).

502 means problem with WSGI.
So let's see the uwsgi logs; you will probably find a huge traceback, but it boils down to an ImportError:

[...]  "No module named xxx"

That's because only the "current" directory is in the PYTHONPATH; not the directory which contains your app and other modules (let's say it's "myapp", so you have /home/dotcloud/current/myapp.manage.py).

We have (at least) the following solutions here:

  1. Change all the code to replace module imports and prepend "myapp" in front of them (not very convenient).
  2. Tweak wsgi.py to add "import sys ; sys.path.append('/home/dotcloud/current/myapp')".
  3. Ttweak the module loader, for example like this: "echo /home/dotcloud/current/myapp > /home/dotcloud/env/lib/python2.6/site-packages/myapp.pth".

 

Of course, you have to restart the service after that, to pick up the new PYTHONPATH ("dotcloud restart myapp.www").

asked Sep 06 '11

jpetazzo gravatar image jpetazzo
363 2 3 7

10 Answers:

i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

I got this Django 404 errors with same logs but none of the solution above solved this issue.

I noticed that the apps that I created with Django dev version (1.4.X) would give me this error (Django 1.3.1 is used on Dotcloud). After replacing the 1.4 dev version with the 1.3.1 on my dev machine, the app created with 1.3.1 would not give me this error and would work properly.

I don't know the underlying reason behind it but at least it solved the issue => check Django version on your development machine.

link

answered Oct 13 '11

jeanbaptiste gravatar image jeanbaptiste
1 2
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

The new and updated Django tutorial is here: http://docs.dotcloud.com/tutorials/python/django/

It will answer your question regarding admin media :-)

link

answered Sep 06 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

I'm currently working on a new and improved version of the Django tutorial. I hope it will help to clear up this issue! :-)

link

answered Aug 30 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

@vivek: looks like I'm late, you already solved your problem — didn't you? (http://e3896987.dotcloud.com/static/admin/css/dashboard.css loads alright now)

link

answered Aug 25 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

@anonymous : patience

@Jérôme : I have my django static files are in " root/static/  " but still get 404 error, like this :

==> /var/log/nginx/djangomongo-default-www-0.error.log <==
2011/08/25 17:20:33 [error] 3050#0: *4 open() "/home/dotcloud/current/static/admin/css/dashboard.css" failed (2: No such file or directory), client: 10.68.47.216, server: djangomongo-default-www-0, request: "GET /static/admin/css/dashboard.css HTTP/1.0", host: "e3896987.dotcloud.com", referrer: "http://e3896987.dotcloud.com/admin/"

I know my file is there in "/home/dotcloud/current/static/admin/css/dashboard.css"
Any guess where I might be going wrong ?

My app is here : http://e3896987.dotcloud.com/

link

answered Aug 25 '11

suho gravatar image suho
1 1 1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

That's strange.
Ealier :
1> I had deleted the "django" folder from "/home/dotcloud/env/lib/python2.6/site-packages/" , in order for python to use the one in my application directory.
2> After I did that I could access by admin page but without any static files.

Now :
1> Now the Django folder seems to be back in site-packages/  and I cant access the admin page
2>Static files are working fine.


:P

link

answered Aug 26 '11

suho gravatar image suho
1 1 1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

I found your query on support. You will get an answer to that request. But we process questions in the following order:

  • first, outages for paying customers (response time is below 30 minutes);
  • then, questions for paying customers (average response time is below 4 hours);
  • then, technical questions for free customers (average response time is below 24 hours);
  • finally, sales inquiries and more complex messages, which can require a couple of days.

Your message was posted thursday night, and was 25 lines long. You then posted an answer that was almost 10 lines long, with more questions. Then you posted more messages saturday night. I understand that you wanted a prompt answer, but I hope you will understand that answering to 40 lines of questions takes some time.

We have a team oncall around the clock, 24 hours/days, 7 days/week. In the night from Sunday to Monday, I was awake at 3 AM because one server had a load issue. Our priority is to address server issues; that means that we are a bit slower to answer to questions, and I'm sorry about that. On the other hand, server issues are fixed very quickly.

Also, I never asked you to open a new forum topic to ask the same question you asked in your support request. I'm sorry if you understood that. You posted messages here to ask about the reliability of our service, and our average response time. I invited you to raise those questions (which are different than the one you ask in your support request) in another topic. Our forum unfortunately does not allow us to move messages to new topics; else I would have done that for more clarity — since the last 6 messages or so have nothing to do with "Django 404 errors" whatsoever.

Best regards,

link

answered Aug 08 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

@anonymous, the Python service allows to deploy Django with minimal effort. Unfortunately, there is still some work to do, but we strive to minimize the boring sysadmin part. Your app just has to follow some conventions. Now, please, if you have questions not related to "Django 404 errors" (the topic you posted to), feel free to ask them again by opening a different topic. That's a basic principle in online forums: don't hijack a topic by polluting it with questions irrelevant to to current subject. We always answer to criticism and negative feedback, so don't worry, your complaints will be addressed — I will make sure that they are, and we will do our best to help you reconsider your first experience with DotCloud.

link

answered Aug 08 '11

jpetazzo gravatar image jpetazzo
363 2 3 7
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

Well anonymous, when you use django you have to have SOME knowledge of python. Dotcloud is 10x easier than trying to set up WSGI for a newbie on a personal server... (trust me, I've tried). And plus, they have an AMAZING free plan, so why you complaining?

link

answered Aug 07 '11

puzzler995 gravatar image puzzler995
1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

I invite you to open new topics on the forum related to those questions; and I promise that we will answer them, don't worry!

link

answered Aug 08 '11

jpetazzo gravatar image jpetazzo
363 2 3 7

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Tags:

Stats:

Asked: Sep 06 '11

Seen: 808 times

Last updated: Oct 13 '11

Powered by Askbot version 0.7.23

Copyright DotCloud, 2011. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.