一,MODELS修改;
1,maxlength-->max_length
2,FloatField-->DecimalField
3,def __str__(self):-->def __unicode__(self):
4,另1.0版的MODELS没有class Admin了,在MODELS的同级目录,有一个新的admin.py文件,1.0将所有的Admin类定义到这个文件去了。
格式如下:
from django.contrib import admin from models import Author class AuthorAdmin(admin.ModelAdmin): list_display = ['first_name', 'last_name'] admin.site.register(Author, AuthorAdmin) #其中Author是在models中定义的类,AuthorAdmin是新定义的,用这句话将他们注册。
(r'^admin/', include('django.contrib.admin.urls')) 代换成 from django.contrib import admin admin.autodiscover() (r'^admin/(.*)', admin.site.root)
#上传LOGO try: buf = request.FILES['logo'] #buf = request.FILES.get('logo',None) (0.96) if buf: data = buf.read() #data = buf['content'] (0.96) f = StringIO.StringIO(data) image = Image.open(f) date = datetime.datetime.now() photoname = '%s-%s.png' % (datetime.datetime.strftime(date,"%Y%m%d%H%M%S"),userid) name = '%s/img/company/%s' % (MEDIA_ROOT,photoname) image.save(file(name,'w'),'png')