Hello and thank you in advance,
When I installed django-profiles and django-registration. I believe I followed a tutorial correctly on how to configure them:
http://agiliq.com/books/djenofdjango/chapter5.html#reusable-apps
Now when I try to access website.com/accounts I get a 404 page:
Using the URLconf defined in acme_p.urls, Django tried these URL patterns, in this order:
^$
^accounts/
^admin/doc/
^admin/
The current URL, accounts, didn't match any of these.
My urls files look like this:
#acme_p urls - Django Project
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', include('user_prof.urls')),
# Examples:
# url(r'^$', 'acme_p.views.home', name='home'),
# url(r'^acme_p/', include('acme_p.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
user_prof urls.py - Django App one level below project mentioned above
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^login/$', 'auth.views.login_user'),
(r'^accounts/', include('registration.urls')),
# (r'^accounts/', include('registration.backends.default.urls')),
)
Thank you for you help.
dp
(r'^accounts/', include('registration.urls')), should be in the root urls.py not the app urls.py
There is no website.com/account in the configuration, there is only website.com/account/(more) where (more) has the rest of the url that is given to the django-registration module. You could try website.com/account/login/ for example to check if the django-registration module is working.
Also you should just put those on the root urls.py file.
Related
I am getting the following error when ever I access the url's except /home.
Page not found (404)
Request Method: GET Request URL
Using the URLconf defined
in report_ui.urls, Django tried these URL patterns, in this order:
^admin/
^home/
The current URL, individual/, didn't match any of
these. You're seeing this error because you have DEBUG = True in your
Django settings file. Change that to False, and Django will display a
standard 404 page.
The code :
urls.py
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, url
urlpatterns = patterns('dnslog.views',
# Examples:
url(r'$', 'home'),
url(r'^report/$', 'report'),
url(r'^angular/$', 'angular'),
url(r'^linear/$', 'LinearPrediction'),
url(r'^splunk/$', 'splunkdata'),
url(r'^toyprediction/$', 'toyprediction'),
url(r'^saleprediction/$', 'GetSalesPrediction'),
url(r'^customerprediction/$', 'GetCustomerPrediction'),
url(r'^monthwiseprediction/$', 'GetMonthWiseSalesPrediction'),
url(r'^getlinearprediction/(?P<duration>.\w+)/$', 'GetLinearPrediction'),
url(r'^getprediction/$', 'GetPredictionReport'),
url(r'^modeldata/(?P<obj>.\w+)/$', 'GetConsolidatedObjectData'),
# url(r'^modeldata/(?P<date>\d{4}-\d{2}-\d{2})/$', 'GetConsolidatedObjectData'),
url(r'^home/(?P<date>\d{4}-\d{2}-\d{2})/$', 'GetConsolidateHits'),
url(r'^bytes/$', 'BytesDownload'),
url(r'^BytesDownload/(?P<date>\d{4}-\d{2}-\d{2})/$',
'GetConsolidateDownloadBytes'),
url(r'^getCntPerData/$', 'GetConsolidateCntPer'),
url(r'^help/$', 'help'),
url(r'^individualhits/$', 'individualhits'),
url(r'^individualhits1/(?P<empid>.+)/(?P<date>\d{4}-\d{2}-\d{2})/$',
'GetIndividualHits'),
url(r'^bubble/$', 'bubble'),
url(r'^bubblechart/(?P<date>\d{4}-\d{2}-\d{2})/$',
'GetConsolidateHitsForBubble'),
#url(r'^test/$', 'test'),
url(r'^domaincloud/$', 'cloud'),
url(r'^getdomaincloud/(?P<date>\d{4}-\d{2}-\d{2})/$', 'Getclouddata'),
url(r'^circleview/$', 'circle'),
url(r'^getcircleview/(?P<date>\d{4}-\d{2}-\d{2})/$', 'Getcircledata'),
url(r'^comparisionview/$', 'comparision'),
url(r'^getcomparision/(?P<date>\d{4}-\d{2}-\d{2})/$', 'Getcomparisiondata'),
url(r'^individualcomparision/(?P<domain>.+)/(?P<empid>.+)/(?P<date>\d{4}-\d{2}-\d{2})/$',
'GetIndividualComparisonData'),
url(r'^trendview/$', 'trend'),
url(r'^gettrendview/$', 'Gettrenddata'),
url(r'^zoomabletree/$', 'zoomabletree'),
url(r'^getzoomabletree/(?P<date>\d{4}-\d{2}-\d{2})/$', 'Getcircledata'),
##url(r'^report_ui/', include('report_ui.foo.urls')),
#url(r'^individualConsolidatedHits/$', 'individualConsolidatedHits'),
url(r'^getConsolidatedCategoryDetails/(?P<date>\d{4}-\d{2}-\d{2})/$',
'getConsolidatedCategoryDetails'),
# overall individual reports
url(r'^individual/$', 'individual'),
## individual Category report
#url(r'^individualcategory/$', 'individualcategory'),
url(r'^GetIndividualCategory/(?P<empid>.+)/(?P<date>\d{4}-\d{2}-\d{2})/$',
'GetIndividualCategory'),
url(r'^twitter/$','twitter'),
root urls.py
from django.conf.urls import patterns, include, url
# to include the media url
from django.conf import settings
from django.conf.urls.static import static
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'report_ui.views.home', name='home'),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'^home/', include('dnslog.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
)
Any help would be appreciated. Thanks!
Either change your root urls.py
url(r'^home/', include('dnslog.urls')),
to:
url(r'^/', include('dnslog.urls')),
Or change your request from
from:
individual/
to:
/home/individual
i am learning django by using django 1.6 documents tutorial 1 - 6.
this round is my 4th try and, previous 3 try was successful and i understand more on every try.
i am in tutorial 3 now, to create views.
according to the documents, after i created a view, i need to map it to a URL.
so i follow the documents to add a urls.py in the polls directory.
and then i follow the document to add include() to mysite/urls.py
i am able to so called wired an index view into the polls view.
now if i go back to localhost:8000, i get an error page,
so my question is
1) WHY?
2) how to get back my localhost:8080 index page co-exist with the polls index page?
thank you very much everyone for your time. i am new and sorry for so simple question.
thank you.
updated:
this is my urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^polls/', include('polls.urls')),
)
this is my polls/urls.py
from django.conf.urls import patterns, url
from polls import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index')
)
the error msg is:
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/
^polls/
The current URL, , didn't match any of these.
http://localhost:8000 index page will be displayed when you created a project (mysite). After creating an application and including it in installed apps in settings.py, you will no longer view the index page of the project, rather your admin page of the application (polls) will be visible at http://localhost:8000/admin
And if you had created any views with the following patterns in polls/urls.py
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^blog/$', views.blog, name='blog'),
)
You need to visit http://localhost:8000/polls for your index page and http://localhost:8000/polls/blogs for your poll blogs page
Editing my answer for step by step approach:
create index.html at polls/templates/polls directory.
in polls/views.py
from django.shortcuts import render_to_response
def pollindex(request):
return render_to_response('polls/index.html', context_instance=RequestContext(request))
in polls/urls.py
urlpatterns = patterns('',
url(r'^index/$', views.pollsindex, name='index'),
)
in your project/urls.py
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)
And now you can view your template index.html at http://localhost:8000/polls/index
I've created a blog using django and hosted it on dotcloud http://www.honeybunny.dotcloud.com/blog/ its working fine on the localhost but when i try to access it online an extra slash is added to the urls what could be the reason ?
www.sitename.com/admin/
becomes
www.sitename.com//admin/
my urls.py is as following
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
import blog
admin.autodiscover()
urlpatterns = patterns('',
url(r'^$',redirect_to,{'url':'/blog'}),
url(r'^admin/', include(admin.site.urls)),
url(r'^blog/',include('blog.urls')),
)
Also submitting the login form on the admin redirects me to http://admin/ while in the local environment it works perfectly fine .
UPDATE : My problem seems remarkably similar to the one described here .
From django tutorials the url file should look like the one below.
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^articles/2003/$', 'news.views.special_case_2003'),
(r'^articles/(\d{4})/$', 'news.views.year_archive'),
(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
(r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
)
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'honeybunny.views.home', name='home'),
# url(r'^honeybunny/', include('honeybunny.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^$',redirect_to,{'url':'/blog'}),
url(r'^admin/$', include(admin.site.urls)),
)
Is my urls.py file
I have deleted import blog line because I don't have blog module.
It seemed to be a problem with dotcloud the same code worked without any errors when i uploaded it to epio
Using Django 1.3 with development server
I try to connect with: http://127.0.0.1:8000/lang/en
The answer is:
Using the URLconf defined in
pruebas.urls, Django tried these URL
patterns, in this order:
^admin/
^correo/$
^login/$
^lang/(?P\w+)/$
^site_static/(?P.*)$
The current URL, , didn't match any of
these.
And this is my "urls.py":
from pruebas import settings
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'pruebas.views.home', name='home'),
# url(r'^pruebas/', include('pruebas.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
(r'^correo/$', 'mailclient.views.index'),
(r'^login/$', 'kusers.views.klogin'),
# Language change
(r'^lang/(?P<lang_code>\w+)/$', 'kusers.views.lang'),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),)
I think that the line:
(r'^lang/(?P\w+)/$', 'kusers.views.lang'),
would match with "http://127.0.0.1:8000/lang/en" but it seems that I'm wrong.
Thanks in advance
The code in kusers/views.py is:
def lang(request, lang_code):
request.session['django_language'] = lang_code
return HttpResponseRedirect( "/" )
SOLVED.
The problem wasn´t urls.py config. The problem was the 'kuser' app folder estructure.
Thanks
If you put a trailing slash on the url it will work, as in:
http://127.0.0.1:8000/lang/en/
In my urls file I have configured the Django admin application to run off the url /adminDJ/. However it doesn't run. It loads up my own admin stuff. Here is my urls.py:
(r'^admin/add/member/$', 'astonomyStuff.attendance.views.newMember'),
(r'^admin/add/$', 'astonomyStuff.attendance.views.addPage'),
(r'^admin/$', 'astonomyStuff.attendance.views.adminPage'),
(r'^adminDJ/$', include(admin.site.urls)),
(r'^talks/$', 'astonomyStuff.attendance.views.talksIndex'),
(r'^talks/past/$', 'astonomyStuff.attendance.views.viewAllTalks'),
(r'^members/$', 'astonomyStuff.attendance.views.viewMembers'),
(r'^members/(?P<member_number>[^/]+)/$', 'astonomyStuff.attendance.views.viewMember'),
(r'^members/(?P<member_number>[^/]+)/delete$', 'astonomyStuff.attendance.views.deleteMember'),
(r'^admin/add/talk/$', 'astonomyStuff.attendance.views.newTalk'),
(r'^talks/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewTalk'),
(r'^attendance/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewAttendance'),
(r'^databrowse/(.*)', databrowse.site.root),
(r'^adminDoc/doc/', include('django.contrib.admindocs.urls')),
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
(r'^accounts/profile/$', 'astonomyStuff.attendance.views.adminPage'),
(r'^admin/add/attendance/$', 'astonomyStuff.attendance.views.addAttendance'),
(r'^members/(?P<member_number>[^/]+)/edit$', 'astonomyStuff.attendance.views.editMember'),
(r'^public/talks/$', 'astonomyStuff.attendance.views.publicViewTalks')
I have rearranged the order to see if this was the problem but that's not fixed it. Must the django admin application run on /admin/?
Edit
I have had the admin application working before just to let you know it only broke when I played around with the urls.
Edit 2
Here is my complete urls.py:
from django.conf.urls.defaults import *
from astonomyStuff.attendance.models import Member
from astonomyStuff.attendance.models import Non_Member
from astonomyStuff.attendance.models import Talk
from astonomyStuff.attendance.models import Event_Attendance
from django.contrib import admin
from django.contrib import databrowse
admin.autodiscover()
admin.site.register(Member)
admin.site.register(Non_Member)
admin.site.register(Talk)
admin.site.register(Event_Attendance)
databrowse.site.register(Member)
databrowse.site.register(Non_Member)
databrowse.site.register(Talk)
databrowse.site.register(Event_Attendance)
urlpatterns = patterns('',
# Example:
# (r'^astonomyStuff/', include('astonomyStuff.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/add/member/$', 'astonomyStuff.attendance.views.newMember'),
# (r'^admin/add/$', 'astonomyStuff.attendance.views.addPage'),
# (r'^admin/$', 'astonomyStuff.attendance.views.adminPage'),
(r'^admin/$', include(admin.site.urls)),
(r'^talks/$', 'astonomyStuff.attendance.views.talksIndex'),
(r'^talks/past/$', 'astonomyStuff.attendance.views.viewAllTalks'),
(r'^members/$', 'astonomyStuff.attendance.views.viewMembers'),
(r'^members/(?P<member_number>[^/]+)/$', 'astonomyStuff.attendance.views.viewMember'),
(r'^members/(?P<member_number>[^/]+)/delete$', 'astonomyStuff.attendance.views.deleteMember'),
# (r'^admin/add/talk/$', 'astonomyStuff.attendance.views.newTalk'),
(r'^talks/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewTalk'),
(r'^attendance/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewAttendance'),
(r'^databrowse/(.*)', databrowse.site.root),
(r'^adminDoc/doc/', include('django.contrib.admindocs.urls')),
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
(r'^accounts/profile/$', 'astonomyStuff.attendance.views.adminPage'),
# (r'^admin/add/attendance/$', 'astonomyStuff.attendance.views.addAttendance'),
(r'^members/(?P<member_number>[^/]+)/edit$', 'astonomyStuff.attendance.views.editMember'),
(r'^public/talks/$', 'astonomyStuff.attendance.views.publicViewTalks'),
)
Not this (r'^adminDJ/$', include(admin.site.urls)),
But this (r'^adminDJ/', include(admin.site.urls)), ##note, no $ in the regex
Remember folks, gotta check your regexes...
This is probably nothing but it caught my eye. From the first snippet:
(r'^admin/$', 'astonomyStuff.attendance.views.adminPage'),
(r'^adminDJ/$', include(admin.site.urls)),
And the second snippet:
(r'^admin/$', include(admin.site.urls)),
Is this how you want it? The first snippet uses ^adminDJ/$ while the second one uses admin/$ opposite include(admin.site.urls).
Are these two files? And are the both used? In that case the first snippet could very well override the second, thereby causing your admin views to show up instead of Django's.