29๐
I think you have edited the wrong file when trying to change the root url config.
Make sure you are editing the root url config in mysite/mysite/urls.py
(the directory containing settings.py
) not mysite/urls.py
(the directory containing manage.py
).
As general advice, install the latest release, currently 1.9. Donโt use 1.10, which is under development. Make sure that you are following the tutorial for 1.9, because the tutorial changes for different versions. For example, your mysite/urls.py
doesnโt match the tutorial for 1.9, as the urlpatterns
should be:
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]
7๐
In settings.py
you have a setting name INSTALLED_APPS-
Adds you app i.e. polls
to it.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
....
'polls',
]
- Django: "order" a queryset based on a boolean field
- Django Rest Ordering custom
- Django template extends not working
1๐
Itโs working. Go to your url bar and type your app name:
http://127.0.0.1:8000/home
My app name is home. It will work.
If you want to set your app as your default page then import views from your app.
Like
from home import views
then write
url(r'^$', views.index),
inside.
It will set the views as your default page
http://127.0.0.1:8000/
When you type this it will redirect to your views.
- Django-tastypie: Any example on file upload in POST?
- External django redirect with POST parameters
- Django Generic Views: When to use ListView vs. DetailView
- How does django's View class work
- Django โ check cookies's "SameSite" attribute
1๐
I had the same problem as described. Running a Windows machine.
It turned out, that the virtual environment I was using had not been configured properly (or maybe I had forgot to activate it before installing Django) and the interpreter and django-admin were fetched from the wrong path by CMD.EXE.
If it appears as if Django is "ignoring" your urls.py โ try deleting everything, re-creating the virtual environment, activating it and re-installing Django afterwards.
1๐
change the mysite/url
from django.conf.urls import patterns,include, url
from django.contrib import admin
urlpatterns = patterns('',
url(r'^&', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)
Then run your server and visit 127.0.0.1/8000.
This should take you to the index of your website.
or you leave your code as it is and run 127.0.0.1/8000/polls on your browser
1๐
Make sure you have path("admin/", admin.site.urls)
in your main url settings.
0๐
I too had same problem going through the official docs tutorial. I was using cloud 9. What I realised before I was able to solve this problem was that while creating the workspace I already chose django(ie by the time my workspace was created, django had already been installed) And going through the tutorial, I again executed $ django-admin startproject mysite
thereby having another layer of django with multiple directories and unavoidably the confusion. My solution was to delete everything and start all over.
- How can I schedule a Task to execute at a specific time using celery?
- Get Celery to Use Django Test DB
0๐
if @Alasdair answer does not work, and it seems your working on correct files, just restart your server
- Access Django devserver from another machine same network
- Configuring django settings to work with 1.4.1. Loading template error
- How does django's View class work
- Database trouble in Django: can't reset because of dependencies
- Celery โ No module named five
0๐
The path in Django 2.2 does not support regular expression , I was using, path('(?P<id>\d+)/share/', views.mail_send_view)
, so getting error, now changed to this, path('<int:id>/share/', views.mail_send_view)
. Now not getting any error. For more info please follow djangoโs official documentation.
- Django redirect to another view with context
- Using a Django variable in a CSS file
- How to get Interdependent dropdowns in django using Modelform and jquery?
- How to use Pagination in a Non-Generic View/Viewset?
-1๐
Checklist:
- Make sure to run the server
>>python manage.py runserver
Watching for file changes with StatReloader
Performing system checksโฆ
System check identified no issues (0 silenced).
February 01, 2020 โ 15:04:46
Django version 3.0.2, using settings โcorona.settingsโ
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
- Open the browser with cmd running, http://127.0.0.1:8000/polls
should be added to the url.