save button not working in django - django

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/post/new/blog/home_page.html
Using the URLconf defined in school.urls, Django tried these URL patterns, in this order:
^admin/
^$ [name='home_page']
^about/$ [name='about']
^event/$ [name='event']
^calendar/$ [name='calendar']
^contact/$ [name='contact']
^class_a/$ [name='class_a']
^login/$ [name='login']
^login_submit/$ [name='login_submit']
^class_info/$ [name='class_info']
^Ist_std/$ [name='Ist_std']
^IInd_std/$ [name='IInd_std']
^IIIrd_std/$ [name='IIIrd_std']
^IVth_std/$ [name='IVth_std']
^post/new/$ [name='post_new']
The current URL, post/new/blog/home_page.html, 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.

Your URL is not matching any of your defined URLs. If you want that page to show anything, you'll need to include a match like:
r'^/post/new/blog/home_page$'
In url.py and write a view for it to display the wanted html file.

Related

django 4.1 tutorial how to change the link on the admin page header from http://localhost:8000 to http://localhost:8000/polls/

In the Admin pages of the Polls Tutorial there is a link to "View Site" that has the URL http://localhost:8000/ but it should be http://localhost:8000/polls/ to list the polls in the indexView class.
I could not find where to change that View Site link.
Right now with the Polls Tutorial done and all working except this last little bit I want to get it done to use as a reference.
http://localhost:8000 now gives...
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
polls/
admin/
The empty path didn’t match any of these.
The best way for me was to change the "View Site" link in the admin header.
go to admin.py and set
admin.site.site_url = 'http://localhost:8000/instruction/'

the current path ,About.html didn't match any of these in django

from django.conf.urls import url
from .import views
urlpatterns = [
url(r'^$', views.index,name='index'),
url(r'^About/', views.About,name='About'),
url(r'^checkout/', views.checkout,name='checkout'),
url(r'^contact', views.contact,name='contact'),
url(r'^faqs', views.faqs,name='faqs'),
url(r'^help', views.help,name='help'),
url(r'^icons', views.icons,name='icons'),
url(r'^payment', views.payment,name='payment'),
url(r'^privacy', views.privacy,name='privacy'),
]
The error message:
Page not found (404)
Request Method:
GET
Request URL:
http://127.0.0.1:8000/About.html
Using the URLconf defined in shop.urls, Django tried these URL patterns,
in this order:
admin/
^$ [name='index']
^about/$ [name='about']
^checkout/$ [name='checkout']
^contact/$ [name='contact']
^static\/(?P<path>.*)$
The current path, About.html, didn't match any of these.
This kind of an error could occur from 2 or 3 different scenarios.
In your case, you seem to put the wrong URL in the browser address bar.
Your correct URL should be http://127.0.0.1:8000/About (as you've written in the URL patterns).
Remember, About.html - is the HTML template you create inside the templates folder. Even though you route to the html page (with a string like: app_name/About.html) - the actual URL in the address bar will be according to what you write in the regex path r'^url_name'. If you write r'^About.html' in url patterns, then http://127.0.0.1:8000/About.html should work perfectly.
The second scenario (based on my experience) which could produce this type of an error is when you forget to pass the 'request' argument inside the method that defines view of the URL - in the respective views.py file.
You should be having a method named About which would look like this in views.py
def About(request):
return render(request,'app_name/About.html')
If you forget to pass argument in the paranthesis of About, this kind of an error could occur.
Finally, if you are using django 2, please start using re_path method to serve regex url patterns. The url method is likely to be depracated in future release.
Refer re_path documentation.
your URL will not be http://127.0.0.1:8000/About.html it will just be http://127.0.0.1:8000/about (remember urls are case insensitive), this will take you to your view which is named About, in your view you should reference your template in its render (about.html)
have you read the my first Django app https://docs.djangoproject.com/en/2.0/intro/tutorial01/ its a great place to start if you are unfamiliar with how django operates
What you are trying to hit is not a valid url, you have to hit http://127.0.0.1:8000/About as written in urls.py.
You have to understand the difference between urls and html templates, this About.html would be used in views while rendering like:
return render(request, 'your_app/about.html')
And for sure you can write a url if you want like this:
urlpatterns = [
url(r'^$', views.index,name='index'),
url(r'^About.html/', views.About,name='About'),
.
.
]
Check the documentation
The url which you provide in url ( ) method doesn't contain any suffix of .html
You can goto the about page directly by /About

I have following messages

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/info
Using the URLconf defined in mysites.urls, Django tried these URL patterns, in this order:
^ ^$ [name='index']
^info/
^admin/
The current path, info, 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.
Issue is that you have to use url(r'^$' or url(r'^ in your views and specify only full url in project dispatcher

Django url pattern doesn't match

I am using new Django 1.8 app to learn Django.
I am stumped as to how to get this my simple url to be resolved by urls.py
I create the url in another view as:
<a href="/photoview/{{photo.id}}/"}>
I can successfully pass this url to the browser as:
http://localhost:8000/photoview/300/
I am expecting that this url can be matched by the urls.py expression:
url('r^photoview/(?P<id>\d+)/$', views.photoview),
But this is not working. I have tried variations of this but none have worked so far, such as:
url('r^photoview/(?P<id>[0-9]+)/$', views.photoview),
I get this message in browser when it fails to match
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/photoview/300/
Using the URLconf defined in asset.urls, Django tried these URL patterns, in this order:
^admin/
^$ [name='index']
^time/$
^about/$
^accounts/$
^photos/$
^tags/$
^users/$
r^photoview/(?P<id>\d+)/$
^static\/photos\/(?P<path>.*)$
The current URL, photoview/300/, didn't match any of these.
Appreciate any help getting this to work.
you have url('r^photoview/(?P<id>\d+)/$', views.photoview),
you want url(r'^photoview/(?P<id>\d+)/$', views.photoview),
(Note the r is in front of the string, not the first character)
As noted in docs.djangoproject.com/en/1.8/topics/http/urls,
The 'r' in front of each regular expression string is optional but
recommended. It tells Python that a string is “raw” – that nothing in
the string should be escaped
Also note that you should use a friendly name in your url definition (e.g. photoview) and then use {% url 'photoview' photo.id %} in your template instead of hardcoding the URL pattern.

Url error in django social auth

I am using django social auth in my app and I found a Page not found error.
I have installed it in my app and also place it in my project parallel to my app.
And I have also add url to my url file
url(r'', include('social_auth.urls')),
But when it shows me the error It shows the list of url in my url file and where i have the required url which i am looking for.
The error page is as :
Page not found (404)
Request Method: GET
Request URL: http://abc.com/login/
Using the URLconf defined in webdev.urls, Django tried these URL patterns, in this order:
^$ [name='home']
^polls/
^admin/doc/
^admin/
^register1/
^edit/
^edit1/
^customerreg/
^checkout/
^checkout1/
^order/
^order1/
^upload/
^upload1/
^product/
^profile/
^logout/
^login/(?P<backend>[^/]+)/$ [name='socialauth_begin']
^complete/(?P<backend>[^/]+)/$ [name='socialauth_complete']
^associate/(?P<backend>[^/]+)/$ [name='socialauth_associate_begin']
^associate/complete/(?P<backend>[^/]+)/$ [name='socialauth_associate_complete']
^disconnect/(?P<backend>[^/]+)/$ [name='socialauth_disconnect']
^disconnect/(?P<backend>[^/]+)/(?P<association_id>[^/]+)/$ [name='socialauth_disconnect_individual']
The current URL, login/, didn't match any of these.
In the above list you can see that url file have that url , but it doesn't access that ??
^login/(?P<backend>[^/]+)/$ [name='socialauth_begin']
This url do not match with http://abc.com/login/ as the url pattern requires a backend parameter.
Something like this will match the url you are accessing, however there is no backend parameter there, so in view you may want to choose something default.
url(r'^login/$', 'your_view',),