Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

python - having trouble configuring Django on the atom editor for a Mac computer

I am trying to set up Django the newest version with python 3 and I keep getting errors about the path way. this is what it is saying and the following is my configurations. Note: I have uninstalled and installed and even wrote it to the exact way their website directs with no luck. it just changes around the error.

terminal:

File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/patrickjobe/Desktop/wordcount/wordcount/urls.py", line 20, in <module>
    path('index/', views.index),
NameError: name 'path' is not defined

urls.py page configs

rom django.contrib import admin
from . import views

urlpatterns = [
    path('index/', views.index),
    path('admin/', admin.site.urls),
]

settings.py page

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS':['templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

views.py page

from django.http import HttpResponse
from django.shortcuts import render

def index(request):
    return render(request, 'index.html')
question from:https://stackoverflow.com/questions/65865868/having-trouble-configuring-django-on-the-atom-editor-for-a-mac-computer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This exception is unrelated to your django installation, and has nothing to do with filesystem paths.

You simply need from django.urls import path before using the path function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...