0

Here is urls.py

path('about/', about, name='about'),

If I visit /about it gives 404 error, if if change it to path('about', about, name='about'), then if I visit /about works but /about/ gives 404 errors.

What am I doing wrong here, this wasn't not happening prior to Django 2.0

Vaibhav Mule
  • 5,016
  • 4
  • 35
  • 52
  • If you are getting this error after upgrading, then it sounds like a duplicate of [this question](https://stackoverflow.com/questions/46497561/after-upgrade-to-django-1-11-append-slash-no-longer-works). – Alasdair Aug 17 '18 at 08:36
  • I didn't upgrade to anything, I have clearly mentioned in the question that I'm using Django 2.0 and that question didn't helped me much. – Vaibhav Mule Aug 17 '18 at 10:43
  • 1
    Yes, I read that you are using Django 2.0. When you say "this wasn't not happening prior to Django 2.0", it looks like you have upgraded Django but did not update your settings. If `/about` does not redirect to `/about/`, that suggests there's a problem with your `MIDDLEWARE` or `APPEND_SLASH` settings. You might find my explanation on [this answer](https://stackoverflow.com/questions/50966180/cant-view-django-2-0-admin-page-after-upgrading/) more helpful. – Alasdair Aug 17 '18 at 10:56

1 Answers1

0

I would comment but I don't have enough reputation to do so yet. Anyways, the following might help:

Did you import your views? Because you're referencing the path() wrong. It should be like:

from . import views

urlpatterns = [

    path('about/', views.about, name='about'),

]
  • I didn't show import statement because the question is about a `path`, if you wanna know here my import `from .views import about` – Vaibhav Mule Aug 23 '18 at 07:30
  • You say you are using `/about` twice. One time it works, and another time it doesn't... Did you write a typo? Also, you said using `/about/` gives an error... Where are you using that? What is your view/template?? – CyberHavenProgramming Aug 23 '18 at 13:50