django condition
Posted infaaf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了django condition相关的知识,希望对你有一定的参考价值。
def index(request,*args,**kwargs): cataloga_obj=Cataloga.objects.all() catalogb_obj=Catalogb.objects.all() # item_obj=Item.objects.all() condition={} for k,v in kwargs.items(): kwargs[k] = int(v) if int(v): condition[k]=int(v) item_obj=Item.objects.filter(**condition) print(kwargs) return render(request,‘index.html‘,{‘cataloga_obj‘:cataloga_obj, ‘catalogb_obj‘:catalogb_obj, ‘item_obj‘:item_obj, ‘kwargs‘:kwargs, })
def index(request,*args,**kwargs): cataloga_obj=Cataloga.objects.all() catalogb_obj=Catalogb.objects.all() # item_obj=Item.objects.all() condition={} for k,v in kwargs.items(): kwargs[k] = int(v) if int(v): condition[k]=int(v) item_obj=Item.objects.filter(**condition) print(kwargs) return render(request,‘index.html‘,{‘cataloga_obj‘:cataloga_obj, ‘catalogb_obj‘:catalogb_obj, ‘item_obj‘:item_obj, ‘kwargs‘:kwargs, })
url
urlpatterns = [ url(r‘^admin/‘, admin.site.urls), url(r‘^index/(?P<cataloga_id>\d+)/(?P<catalogb_id>\d+)‘, views.index), ]
以上是关于django condition的主要内容,如果未能解决你的问题,请参考以下文章
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)(代码片段
etag&last_modified&condition& django.middleware.http.ConditionalGetMiddleware