django-models - 没有名为 django.urls 的模块
问题描述
我正在尝试创建一个新模型,我将其命名为产品,我发现了您在下面看到的此错误消息
请注意,我的 django 版本是 1.8.7
##urls.py:
from django.contrib import admin
from mySecondGdgBlogs import views
from django.urls import include, path
from myGdgBlogs import views
urlpatterns = [
path('admin/', admin.site.urls),
path('writeafterme/',include('mySecondGdgBlogs.urlss')),
path('htm/', views.htamal),
path('dp/',views.dpmain)
]
##views.py:
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def dbmain(request):
data = ''
return HttpResponse(data)
##models.py
from django.db import models
# Create your models here.
class Products(models.Model):
name = models.CharField (max_length=20)
price = models.IntegerField()
type=models.CharField(max_length=20,choices=(
('S', 'Small'),
('M', 'Medium'),
('L', 'Large'),
))
class Meta:
db_table = 'Products'
我希望向我展示一个白页,但浏览器中的实际结果是:
No module named 'django.urls'
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.7
Exception Type: ModuleNotFoundError
Exception Value:
No module named 'django.urls'
Exception Location: /home/mohammed/PycharmProject/GdgProject/myGdgProject/myGdgProject/urls.py in <module>, line 7
Python Executable: /usr/bin/python3
Python Version: 3.6.8
Python Path:
[
'/home/mohammed/PycharmProject/GdgProject/myGdgProject',
'/usr/local/lib/python3.6/dist-packages/pip-19.1.1-py3.6.egg',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/home/mohammed/.local/lib/python3.6/site-packages',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages'
]
解决方案
推荐阅读
- r - R - 投资组合分析优化不起作用
- graph - 在图数据结构的同级顶点上实现 BFS
- python - 为最小化设置 Scipy 不等式约束
- css - Sass 中的@content 是做什么用的?
- excel - 根据重复项和最低价格分配值
- autodesk-forge - 在 Forge 查看器中更改元素的属性和不透明度
- go - 使用带时间和超时的作业
- pagination - 使用带有分页的 DynamoDB 扫描操作而不是使用 GSI 查询是否正确,我需要表中的所有项目
- java - 在 quarkus 中使用 java 反射
- css - Angular 材质表单域类“mat-form-field-outline”无法使用 css 选择器进行修改