cho*_*obo 4 django-generic-views django-class-based-views django-1.4
我想在views.py中调用基于类的通用视图
请看我的代码......
urls.py
from django.conf.urls import patterns, include, url
from crm.views import *
urlpatterns = patterns('',
(r'^workDailyRecord/$', workDailyRecord),
)
Run Code Online (Sandbox Code Playgroud)
和我的views.py ....请看...
views.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"
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
试试这个:
def workDailyRecord(request):
if request.method === 'GET':
return tView.as_view()(request)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2899 次 |
| 最近记录: |