2006年04月27日 星期四 22:15
#---------我的 models file------------------- #coding=utf-8 from django.db import models # Create your models here. class Note(models.Model): items = models.CharField('条目', maxlength=400) money = models.FloatField('价格', max_digits=5, decimal_places=2) tagIds = models.CharField('标签',maxlength=40) memo = models.TextField('说明', blank=True) addtime = models.DateTimeField('时间') def __repr__(self): return self.items class Admin: pass class META: ordering = ['-addtime'] class Tag(models.Model): title = models.CharField('名称', maxlength=50) count = models.IntegerField("使用数") class Admin: pass def __repr__(self): return self.title #---the urls file ------------------ from django.conf.urls.defaults import * from finacing.note.models import * info_dict = { 'queryset': Note.objects.all(), } urlpatterns = patterns('', (r'^/*$', 'django.views.generic.list_detail.object_list',dict(paginate_by=2, **info_dict)), (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': 'F:\\djangoPrj\\finacing\\media'}), # Example: # (r'^finacing/', include('finacing.apps.foo.urls.foo')), # Uncomment this for admin: (r'^add/$', 'finacing.note.views.add'), (r'^addtag/$', 'finacing.note.views.addtag'), (r'^admin/', include('django.contrib.admin.urls')), ) 我改变ordering如下,但是列表排序没有变化,还是按数据库里的顺序: class META: ordering = ['addtime'] 有谁用过ordering的帮我看看阿。 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060427/90712205/attachment.html
Zeuux © 2025
京ICP备05028076号