NameError: Name 'path' is not defined - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: NameError: Name 'path' is not defined (/thread-11235.html) |
NameError: Name 'path' is not defined - aniyanetworks - Jun-29-2018 Hello folks, I am completely new in Python programming, and at beginning of the day, I am having some issues. Hope you guys will help me pass through the issue. The error shows on my CMD: path(r'^admin/', admin.site.urls), NameError: name 'path' is not defined MySite: urls.py-AboutUs Quote:from django.conf.urls import urlviews.py Quote:from django.http import httpresponseurls.py-My1stDjangoSite Quote:from django.conf.urls import include, url IDE: Atom RE: NameError: Name 'path' is not defined - gontajones - Jun-29-2018 You have to import the path module:from django.urls import pathBTW, what version of Django are you using? RE: NameError: Name 'path' is not defined - aniyanetworks - Jun-29-2018 Hello Gontajones, Thanks for your reply. Django version is : (2, 1, 0, 'beta', 1) After I made changes I am getting now different Error (as you suggested). Quote: path(r'^aboutus/', include('aboutus.urls')), RE: NameError: Name 'path' is not defined - gontajones - Jun-29-2018 What is aboutus ? It is an app, right?You have to import it too. import aboutus RE: NameError: Name 'path' is not defined - aniyanetworks - Jun-29-2018 Yes, Aboutus is an App. where should I add this "import aboutus " ? on root urls.py or under my apps ulrs.py? Sorry if you found this is silly questions, i am new. RE: NameError: Name 'path' is not defined - gontajones - Jun-29-2018 Where do you call it? Usually is on your root urls.py (project urls.py). RE: NameError: Name 'path' is not defined - aniyanetworks - Jun-29-2018 Here is the link of Image. https://ibb.co/de1rGd please take a look Thanks RE: NameError: Name 'path' is not defined - gontajones - Jun-29-2018 What is the name of the app, AboutUs or abautus? You have to use the exact name as include('app_name.urls') parameter: # For app name AboutUs path('aboutus/', include('AboutUs.urls') # Or # For app name aboutus path('aboutus/', include('aboutus.urls')And the file urls.py must exists inside the app's folder. RE: NameError: Name 'path' is not defined - aniyanetworks - Jun-29-2018 Perfect, Thanks Gontajones it was Case sensitive i used, path('aboutus/', include('AboutUs.urls') and after that i was getting Quote:Request Method: GET then i changed to Quote:django.http import HttpResponseand it works. Thank you for your time. RE: NameError: Name 'path' is not defined - gontajones - Jun-29-2018 Yep, now you got it! When you use something from external modules, you have to import them. |