class WriteNewsView(View):
def get(self,request):
categories = NewsCategory.objects.all()
context = {
'categories': categories
}
return render(request,'cms/write_news.html',context=context)
{% for category in categories %}
{% if news and news.category_id == category.pk %}
{% else %}
{% endif %}
{% endfor %}
import qiniu
@require_GET
def qntoken(request):
#个人中心 >>密钥管理
access_key ='0Vdby2POAWO7Ox2bPTSlwYmDUbXoH_3mf34sezCo'
secret_key ='mlF9T9byihASXLEzA-DD-8qAEOu4fLNJXnc1asO0'
#空间名称
bucket ='xhdake'
q =qiniu.Auth(access_key,secret_key)
token =q.upload_token(bucket)
return restful.result(data={"token":token})
path('qntoken/',views.qntoken,name='qntoken'),