Writing your first Django app, part 1 - Can't Follow it

876 views
Skip to first unread message

michaela...@gmail.com

unread,
Feb 9, 2016, 7:22:58 PM2/9/16
to Django users
Hi,

I am running into the same problem as this:
http://stackoverflow.com/questions/30493018/404-error-in-writing-your-first-django-app-tutorial

Now I can just follow the Alasdair's recommendation and delete the polls/url.py file, but the tutorial is very clear about having two separate urls.py.
Is this a mistake in the tutorial?

I even copied and pasted the tutorials code and tried to run it and it still gave the same error:
ImportError: No module named 'polls.urls'

Very confusing for a first step tutorial, maybe this could be corrected if it is an issue?

Kind Regards

Bipul Raj

unread,
Feb 9, 2016, 9:48:11 PM2/9/16
to django...@googlegroups.com
I remember doing the django tutorial long time back, it just works.

The import error means that file polls/urls.py is not there. Check may be you have left "s" in ulrs. You might have created polls/url.py.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/44703fc1-518a-4a25-ae56-4a7b2992860a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thiago Reis

unread,
Feb 9, 2016, 9:55:07 PM2/9/16
to django...@googlegroups.com
I believe it is because your (MySite) is in upper case.

ROOT_URLCONF = 'mysite.urls'
must be:
ROOT_URLCONF = 'MySite.urls'

Thiago Reis

unread,
Feb 9, 2016, 9:59:00 PM2/9/16
to django...@googlegroups.com
* 'Mysite.urls"

michaela...@gmail.com

unread,
Feb 10, 2016, 5:26:31 AM2/10/16
to Django users
Hi, thank you that was it!

James Schneider

unread,
Feb 10, 2016, 5:30:48 AM2/10/16
to django...@googlegroups.com


On Feb 9, 2016 4:22 PM, <michaela...@gmail.com> wrote:
>
> Hi,
>
> I am running into the same problem as this:
> http://stackoverflow.com/questions/30493018/404-error-in-writing-your-first-django-app-tutorial
>
> Now I can just follow the Alasdair's recommendation and delete the polls/url.py file, but the tutorial is very clear about having two separate urls.py.
> Is this a mistake in the tutorial?

If you follow the official tutorial, you will have two urls.py files.

One is located at mysite/mysite/urls.py, having been created by the 'startproject' command. This is your primary urls.py file that is referenced in your settings.py as the starting point for all URL lookups by default, as automatically configured by the 'startproject' command.

The second will be located at mysite/polls/urls.py, and is created by the 'startapp' command listed in the tutorial. This file is referenced by your primary project urls.py using an include() function. Any URL's that match the regular expression for the include statement in your primary file will then begin searching through your app urls.py for further matches.

If you are on a Linux host, everything is case-sensitive, so make sure your upper/lower case code references match your actual directory structure.

-James

Sammy Agrawal

unread,
Jul 31, 2019, 7:20:35 AM7/31/19
to Django users
Still having this problem- no solution found

Karan Mittal

unread,
Jul 31, 2019, 7:26:13 AM7/31/19
to django...@googlegroups.com
Give the polls.urls in quotes like this. 
"polls.urls"

Karan Mittal

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Lim Kai Wey

unread,
Jul 31, 2019, 10:42:00 AM7/31/19
to django...@googlegroups.com
To Sammy,

Are you sure your urls.py is in the correct file directory? As in it should be in mysite/mysite/urls.py instead of mysite/urls.py

Regards,
Kai Wey

Charlotte Wood

unread,
Jul 31, 2019, 10:46:45 AM7/31/19
to django...@googlegroups.com
Windows?

--

Sammy Agrawal

unread,
Jul 31, 2019, 2:03:32 PM7/31/19
to django...@googlegroups.com
I’m on Mac, and am still having this problem.
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/dV46T9ZqPhA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPZR0N5XnyD%2BeG8ND-Uq%3DnkNEAM4hcjHsX%2BmxO2YLD-b0RCZxQ%40mail.gmail.com.
--
- Sammy

Sammy Agrawal

unread,
Jul 31, 2019, 2:04:37 PM7/31/19
to Django users

IMG_1708.jpg

Sammy Agrawal

unread,
Jul 31, 2019, 2:05:05 PM7/31/19
to Django users

IMG_1710.jpg



On Wednesday, July 31, 2019 at 10:42:00 AM UTC-4, Lim Kai Wey wrote:

Sammy Agrawal

unread,
Jul 31, 2019, 2:05:05 PM7/31/19
to Django users
To Lim Kai Wey,

IMG_1713.jpg

I am fairly certain that the directory is not the problem. However, since this is my first Django project, I am pretty certain I've missed something. I attached some pictures to better illustrate what I've done. 


On Wednesday, July 31, 2019 at 10:42:00 AM UTC-4, Lim Kai Wey wrote:

Lim Kai Wey

unread,
Jul 31, 2019, 8:33:21 PM7/31/19
to django...@googlegroups.com
Sammy, would you mind attaching the whole project folder? Thanks

Regards,
Kai Wey

Anike Sadia

unread,
Jul 31, 2019, 8:38:43 PM7/31/19
to django...@googlegroups.com
Hi I am new here

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Franck Tchouanga

unread,
Aug 1, 2019, 5:59:14 AM8/1/19
to Django users
Got the solution to your problem

Franck Tchouanga

unread,
Aug 1, 2019, 6:04:11 AM8/1/19
to Django users
Firstly in your mysite/mysite/URLs.py in the url patterns portion instead type this

Urlpatterns=[

Path('',include ('polls.URLs')),
Path('admin/',admin.site.URLs),
]

Franck Tchouanga

unread,
Aug 1, 2019, 6:08:22 AM8/1/19
to Django users
In the mysite/mysite/setting.py do as follows

INSTALLED_APPS=[
'Polls.apps.pollsConfig',
""""
The rest of the code
"""
]


So you should erase the polls you wrote at the end. Hope will be helpful waiting for your feedbacks

Franck Tchouanga

unread,
Aug 1, 2019, 6:16:49 AM8/1/19
to Django users
I wanted to precise at the level of the syntax from what I wrote above

Urlpatterns = [

Path(' ',include('polls.URLs')),

Path('admin/', admin.site.urls),
]

Lim Kai Wey

unread,
Aug 1, 2019, 6:36:46 AM8/1/19
to django...@googlegroups.com
I do agree that you Sammy could try changing the mysite/mysite/setting.py

  INSTALLED_APPS=[
        'polls.apps.PollsConfig',

         """"
           The rest of the code
          """
       ]  

And I too was wondering if he placed 'polls/' as his URL in mysite/polls/urls.py that cause the error. (IF that is the case)
But in my opinion, for future development purposes and good practice to know which django app you are at while browsing at webpage.
Remain the mysite/mysite/urls.py as it is. The code should be:

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]

and instead change the mysite/polls/urls.py The code should be:

from django.urls import path
from . import views

urlpatterns = [
path('', views.IndexView.as_view(), name='index'),
]

Please do correct me if I am wrong. Hope it helps.

Regards,
Kai Wey

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Lim Kai Wey

unread,
Aug 1, 2019, 6:42:24 AM8/1/19
to django...@googlegroups.com
Besides that, I do recommend Morzilla's Django Tutorial too, as it covers more in the tutorial compared to Django's own tutorial.

Link:

Regards,
Kai Wey

Nde Nguti

unread,
Aug 1, 2019, 7:07:19 AM8/1/19
to django...@googlegroups.com
Just out of curiosity, Python is case sensitive. The function names, 'path' and variable 'urlpatterns'.  I have gone through the tutorials with no problem.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Sunny Kumar

unread,
Aug 1, 2019, 7:07:48 AM8/1/19
to django...@googlegroups.com
Hi,

I also having the same problem. And the actual reason was (poll instead of polls). Please check once in your view or url file. I am sure you also having the same issue.



Mailtrack Sender notified by
Mailtrack 08/01/19, 10:43:28 AM

Rana Sarkar

unread,
Aug 1, 2019, 7:13:03 AM8/1/19
to django...@googlegroups.com
You check your app name ,then check 
Include ('appname.urls')
U also create urls.py inside your app.

Sammy Agrawal

unread,
Aug 1, 2019, 7:13:22 AM8/1/19
to django...@googlegroups.com
Thank you all so much! Franck's suggestion did it and now I'm further along on my Django journey! 

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/dV46T9ZqPhA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPcVkjiSOhVSGpUYBSfAAo%2BLXdRrR6_k3-ydjXu76ZatsbNmZQ%40mail.gmail.com.
Screen Shot 2019-08-01 at 7.09.49 AM.png

Franck Tchouanga

unread,
Aug 1, 2019, 7:21:52 AM8/1/19
to django...@googlegroups.com
Yes, so respect the syntaxes exactly it is written by default in django, its a better practice to avoid unwanted errors.

Just need to  give modification depending on the project you created

Franck Tchouanga

unread,
Aug 1, 2019, 7:34:17 AM8/1/19
to django...@googlegroups.com
cooolllll am glad it was helpful. Welcome .

Lim Kai Wey

unread,
Aug 1, 2019, 7:55:40 AM8/1/19
to django...@googlegroups.com
Glad it all worked out. Good luck at your journey.
Reply all
Reply to author
Forward
0 new messages