27π
You are getting the 404 because you havenβt defined a url pattern for http://127.0.0.1:8000/
yet.
You should be able to view the admin site at http://127.0.0.1:8000/admin/
and your food posts at http://127.0.0.1:8000/foodPosts/
.
To add a url pattern for the homepage, uncomment the following entry in your urls.py, and replace homefood.views.home
with the path to the view you want to use.
url(r'^$', 'homefood.views.home', name='home'),
3π
Basically the answer to this to add a entry in the project urls.py file as blank example:
path('', include('MYAPP.urls')),
and in the app urls.py you add this
url('MYAPP', views.index),
make sure in the settings.py you include your app also make sure in the app urls.py you import your views
- [Django]-Django select_for_update cannot be used outside of a transaction
- [Django]-How to use Django ImageField, and why use it at all?
- [Django]-How to test "render to template" functions in django? (TDD)
2π
I had this error too and the solution was to change double quotes to single quotes for the name=
parameter in the urls.py
file of the concerned app!
path('register', views.register, name='register')
- [Django]-How to get superuser details in Django?
- [Django]-Is there a way to filter a queryset in the django admin?
- [Django]-How to access Enum types in Django templates
1π
Not directly relevant to the OP, but maybe useful for others:
My admin pages all went 404 after I accidentally removed the trailing slash from the path()
route (django 3.2):
urlpatterns = [
path('admin', admin.site.urls), # trailing slash missing...
path('', include('myapp.urls'))
]
This was easily fixed by restoring to 'admin/'
.
- [Django]-How can I handle Exceptions raised by dango-social-auth?
- [Django]-How do I reuse HTML snippets in a django view
- [Django]-How do I run tests against a Django data migration?
0π
Itβs work for me by just added / in the end of βusersβ
in urls.py app file
look like this
path('users/', get_users, name='users')
- [Django]-Difference between User.objects.create_user() vs User.objects.create() vs User().save() in django
- [Django]-How to get getting base_url in django template
- [Django]-Get object by field other than primary key
0π
I got the same error below:
Page not found (404)
Because I didnβt put /
after test/<int:id>
as shown below:
urlpatterns = [ # β Here
path('test/<int:id>', views.test, name="test")
]
So, I put /
after test/<int:id>
as shown below, then the error was solved:
urlpatterns = [ # β Here
path('test/<int:id>/', views.test, name="test")
]
- [Django]-"<Message: title>" needs to have a value for field "id" before this many-to-many relationship can be used.
- [Django]-Get the list of checkbox post in django views
- [Django]-How do you use the django-filter package with a list of parameters?
0π
You only see the landing page when there are NO URLS defined:
As soon as you configure a URL (e.g foodPosts/
) , the /
route will NOT show the landing page unless you explicitly define a /
route in urls.py
Hence you donβt see that rocket with this link : http://127.0.0.1:8000/
- [Django]-Speeding up Django Testing
- [Django]-Warning: Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'
- [Django]-Using django-rest-interface