即时通讯使用通用视图,我想更新另一个数据库表中的字段(most_view)。
当用户阅读文章时,如何更新或为“大多数视图”创建新注册表?
ulrs.py
from Paso_a_Paso.noticias.models import Noticia
noticias_info_dict = {
'queryset':Noticia.objects.all(),
'date_field':'pub_date',
}
urlpatterns = patterns('django.views.generic.date_based',
(r'^$','archive_index', noticias_info_dict,'noticias_archive_index'),
(r'^(?P<year>\d{4})/$','archive_year', noticias_info_dict,'noticias_archive_year'),
(r'^(?P<year>\d{4})/(?P<month>\w{3})/$','archive_month', noticias_info_dict,'noticias_archive_month'),
(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/$','archive_day', noticias_info_dict,'noticias_archive_day'),
(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$','object_detail', noticias_info_dict,'noticias_archive_detail'),
)
谢谢你们:)
答案 0 :(得分:0)
使用当前的通用视图(class-based generic views会有所帮助)没有真正干净的方法。
你可以:
或