Page not found (404) Request Method: GET - django

Request Method: GET
Request URL: http://127.0.0.1:8000
Using the URLconf defined in DjangoAPI.urls, Django tried these URL patterns, in this order:
admin/
^ ^department$
^ ^department/([0-9]+)$
^ ^employee$
^ ^employee/([0-9]+)$
^ ^employee/savefile
^ ^Photos/(?P<path>.*)$
The empty path didn't match any of these
Yesterday the Django portion of the project was fine and now I'm getting this error message. I've tried adding /home/ at the end of 127.0.0.1:8000 and still getting the same thing. Any help would be greatly appreciated.

Related

URL /testform handler does not match any handler

I'm trying to make a simple form that receives an input from the user and respond by displaying same input on the webpage using python2.7 and Google app engine running locally.Using SublimeText. I'm getting errors "HTTP ERROR 500" and tried to solve it as shown below but no luck.
This is the app.yaml file:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
script: test.app
This is the test file:
import webapp2
form="""
<form action="/testform">
<input name= "q">
<input type="submit">
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
class TestHandler(webapp2.RequestHandler):
def get(self):
q = self.resquest.get("q")
self.response.out.write(q)
app = webapp2.WSGIApplication([('/', MainPage), ('/testform', TestHandler)], debug=True)
When I run the file above I receive this message:
The url "/testform" does not match any handlers.
I already try including a separate handler for the /testform URL:
handlers:
- url: /
script: test.app
- url: /testform
script: test.app
When I do that then I receive the following message:
localhost is currently unable to handle this request.
HTTP ERROR 500
I also try changing / to .* and also to /.* on the app.yaml file to handle all URL's like this:
handlers:
- url: .*
script: test.app
and:
handlers:
- url: /.*
script: test.app
Having the same result:
localhost is currently unable to handle this request.
HTTP ERROR 500
Converting comments to an answer to not leave the question hanging.
In the initial version of you app.yaml file you only have one handler with the url: / pattern. The /testform request doesn't match this single handler, which explains the initial error message:
The url "/testform" does not match any handlers.
All subsequent attempts went OK from handler mapping prospective (I'd go for the url: .* one as it's shorter, but that's just a personal preference, any of them should do), the error message actually changed into:
localhost is currently unable to handle this request. HTTP ERROR 500
But this error has a different root cause - the resquest vs request typo in the (now properly mapped) TestHandler.get() method.

Django's URL regex engine is failing

Django's URL regex engine is failing and I have no idea why. Even my sanity checks are failing horribly.
Here's my urls.py:
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^a', 'placemyorder.views.home', name='home'),
)
I get this 404 error:
Page not found (404)
Request Method: GET
Request URL: http://[ip address]/a/
Using the URLconf defined in placemyorder.urls, Django tried these URL patterns, in this order:
1. ^a [name='home']
The current URL, , didn't match any of these.
when I visit
http://[ip address]/a
And it's hosted on Django 1.5.2 with Python 2.7.3 on Ubuntu 12.04 behind nginx if that info is relevant.
Here's a clue: The current URL, , didn't match any of these.
It should say: The current URL, http://[ip address]/a, didn't match any of these.
So the dispatcher isn't getting the request url.
Take a look at this solution:
Django + NGINX URL Problem

little trouble while trying to run emencia.django.newsletter

I did exactly (or so I think) as the docs describe to install emencia.django.newsletter (https://github.com/Fantomas42/emencia-django-newsletter). I installed all dependencies and emencia.django.newsletter from github. All installed successfully.
I also added this in my urls.py
urlpatterns += patterns('',
url(r'^newsletters/', include('emencia.django.newsletter.urls')),
)
I synced the database and when I give http://localhost:8000/newsletters/ (even having logged in as admin) I get a 404 error page.
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/newsletters/
[...]
^newsletters/ ^mailing/
^newsletters/ ^tracking/
^newsletters/ ^statistics/
^newsletters/ ^ ^preview/(?P<slug>[-\w]+)/$ [name='newsletter_newsletter_preview']
^newsletters/ ^ ^(?P<slug>[-\w]+)/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$ [name='newsletter_newsletter_contact']
^dowser/
^media/(?P<path>.*)$
Where did I go wrong?
Obviously there is no page at /newsletters/ as you can see in the urls.py.
Try /newsletters/mailing/

404Error When I open /admin/appname/ on Apahce(mod_wsgi)

When I open /admin on my local domain use development server,It all work.
When I move this project to Apache,Other pages work normal,But When I open admin site,click 'All' or 'Change',I get a 404 Error
Page not found (404)
Request Method: GET
Request URL: http://localdomain/admin/article/article/
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/ ^$
^admin/ ^logout/$
^admin/ ^password_change/$
^admin/ ^password_change/done/$
^admin/ ^jsi18n/$
^admin/ ^r/(?P\d+)/(?P.+)/$
^admin/ ^(?P\w+)/$
The current URL, admin/article/article/, didn't match any of these.
Thanks in advance for any help.
Where did you get this url admin/article/article/? This pattern should have been defined in your urls.py file right?

admin/appname/modelname urls does not work with mod_wsgi in Django 1.1rc1

I'm using Django 1.1 rc1 and Apache 2.2.8 on Ubuntu with mod_wsgi 1.3.1 + Python 2.5.2.
Everything worked fine with Django's internal testing web server, but after migrating to Apache mod_wsgi, all urls like /admin/appname/modelname/ began not to work. They shows 404 not found errors with the following log:
...
^admin/ ^$
^admin/ ^logout/$
^admin/ ^password_change/$
^admin/ ^password_change/done/$
^admin/ ^jsi18n/$
^admin/ ^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$
^admin/ ^(?P<app_label>\w+)/$
The current URL, admin/account/userprofile/, didn't match any of these.
Strangely, /admin/appname/ and all other parts including my custom urls just work fine.
Is it a bug of Django or configuration issue? And how to solve it?
I know that 1.1RC1 made some changes to the admin URL resolver to use namespaces: this might be your problem.
see here: http://docs.djangoproject.com/en/dev/releases/1.1-rc-1/
Other than that it looks like the URLs are not correct as the last line of the urls in the debug trace would only match /admin/app/ rather than /admin/app/xxxx. The information here might help.
for some reason this ^admin/ ^r/(?P\d+)/(?P.+)/$ doesn't look right wouldn't that give /admin//xxx/yyy/ ?
Edit: no it gives /admin/r/xxx/yyy/
I can't test this right now as I only have 1.0.2 available on this computer (and no mod_wsgi) - I will test on 1.1 when I get home tonight.
Edit: Looks like this
for model, model_admin in self._registry.iteritems():
urlpatterns += patterns('',
url(r'^%s/%s/' % (model._meta.app_label, model._meta.module_name),
include(model_admin.urls))
)
return urlpatterns
is not working for some reason, as the URLs are not included in the search path in the debug trace. Are the admin.py files correct?