gpt4 book ai didi

django-class-based-views - Django : How to call class-based generic views in views. py?

转载 作者:行者123 更新时间:2023-12-04 23:05:01 25 4
gpt4 key购买 nike

我想在 views.py 中调用基于类的通用 View

请看我的代码...

网址.py

from django.conf.urls import patterns, include, url
from crm.views import *

urlpatterns = patterns('',
(r'^workDailyRecord/$', workDailyRecord),
)

和我的意见.py....请看...

View .py
from django.views.generic import TodayArchiveView
from crm.models import *

def workDailyRecord(request):
if request.method == 'GET':
tView.as_view() # I want call class-based generic views at this line.
elif:
"""
Probably this part will be code that save the data.
"""
pass

class tView(TodayArchiveView):
model = WorkDailyRecord
context_object_name = 'workDailyRecord'
date_field = 'date'
template_name = "workDailyRecord.html"

我应该怎么办?

最佳答案

Try this :

def workDailyRecord(request):
if request.method === 'GET':
return tView.as_view()(request)

关于django-class-based-views - Django : How to call class-based generic views in views. py?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14547384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com