models.py
from django.db import models
class Dhiraj(models.Model):
name=models.CharField(max_length=100)
email=models.EmailField(max_length=100)
password=models.CharField(max_length=100)
forms.py
from django.forms import fields
from .models import Dhiraj
class StudentRegistation(forms.ModelForm):
class Meta:
models=Dhiraj
fields=['name','email','password']
管理员
from django.contrib import admin
from .models import Dhiraj
@admin.register(Dhiraj)
class DhirajAdmin(admin.ModelAdmin):
list_display=('id','name','email','password')
views.py
from crudproject1.enroll.forms import StudentRegistation
from django.shortcuts import render
from .forms import StudentRegistation
def add_show(request):
if request.method=='POST':
fm=StudentRegistation(request.post)
else:
fm=StudentRegistation(request.post)
context={
'fm':fm
}
return render(request,'enroll/addandshow.html')
url.py
from django.contrib import admin
from django.urls import path
from enroll import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.add_show, name="addandshow")
]
文件“C:\Users\Dhiraj Subedi\Desktop\Dhiraj\crudproject1\crudproject1\url.py”,第18行,在 从注册导入视图 文件“C:\Users\Dhiraj Subedi\Desktop\Dhiraj\crudproject1\enroll\views.py”,第1行,在 从crudproject1.enroll.forms导入学生注册 ModuleNotFoundError:没有名为“crudproject1.enroll”的模块
我正在创建一个Django应用程序,我正面临这个问题,你能帮我吗
`
您可以从同一应用程序的
forms
模块导入StudentRegistation
(可能应该重命名为StudentRegistration
)。因此,您可以通过以下方式导入此文件:或与之相关的:
相关问题 更多 >
编程相关推荐