本文整理汇总了Python中models.Album.append方法的典型用法代码示例。如果您正苦于以下问题:Python Album.append方法的具体用法?Python Album.append怎么用?Python Album.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Album
的用法示例。
在下文中一共展示了Album.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import append [as 别名]
def create_album(request):
if not request.user.is_authenticated():
return redirect('/')
if request.method=='GET':
albums=Album.objects.all()
print albums
maincat=MainCat.objects.all()
nart,cart,rart,cm,tg=getthree()
#日历
today=today=datetime.datetime.now()
s=calendar.HTMLCalendar(6)
cals=list(s.itermonthdays2(today.year,today.month))
tdarts=Article.objects.values('id','createtime').filter(createtime__year=today.year,createtime__month=today.month).order_by('createtime') #列表字典[{'createtime': datetime.datetime(2014, 4, 6, 4, 36, 32, 896000, tzinfo=<UTC>)},
tdart=set([i['createtime'].day for i in tdarts])
tmpq=Article.objects.exclude(createtime__year=today.year,createtime__month=today.month)
premon=tmpq.filter(createtime__lt=today).order_by('-createtime')[:1]
aftmon=tmpq.filter(createtime__gt=today).order_by('createtime')[:1]
tt=[]
for i in cals:
tt.append(list(i))
ttt=[]
for a in tt:
for i in tdart:
if a[0] == i:
a.append(1)
if len(a)==2:
a.append(0)
ttt.append(a)
return render_to_response('create_album.html',locals(),context_instance=RequestContext(request))
else:
albumpath=request.POST['albumpath']
albumname=request.POST['albumname']
a=Album(album_name=albumname,album_path=albumpath)
a.save()
maincat=MainCat.objects.all()
nart,cart,rart,cm,tg=getthree()
#日历
today=today=datetime.datetime.now()
s=calendar.HTMLCalendar(6)
cals=list(s.itermonthdays2(today.year,today.month))
tdarts=Article.objects.values('id','createtime').filter(createtime__year=today.year,createtime__month=today.month).order_by('createtime') #列表字典[{'createtime': datetime.datetime(2014, 4, 6, 4, 36, 32, 896000, tzinfo=<UTC>)},
tdart=set([i['createtime'].day for i in tdarts])
tmpq=Article.objects.exclude(createtime__year=today.year,createtime__month=today.month)
premon=tmpq.filter(createtime__lt=today).order_by('-createtime')[:1]
aftmon=tmpq.filter(createtime__gt=today).order_by('createtime')[:1]
tt=[]
for i in cals:
tt.append(list(i))
ttt=[]
for a in tt:
for i in tdart:
if a[0] == i:
a.append(1)
if len(a)==2:
a.append(0)
ttt.append(a)
return render_to_response('create_album.html',locals(),context_instance=RequestContext(request))