>>> a = group.objects.order_by('groupname')
>>> print a
[<group: beginner 593785332>, <group: beginner 903647323>, <group: blbrz 229225098>]
我不想拥有相似的对象goupname
,我希望groupname
每个对象都有不同的:
[<group: beginner 593785332>, <group: blbrz 229225098>]
我能做些什么?
from django.db import models
class accounts(models.Model):
twitterid = models.IntegerField()
credit = models.IntegerField()
activate = models.TextField()
ban = models.TextField(blank=True)
others = models.TextField()
def __unicode__(self):
return u'%s' % (self.twitterid)
class Meta:
ordering = ['twitterid']
class group(models.Model):
groupname = models.TextField()
accounts=models.ForeignKey(accounts)
def __unicode__(self):
return u'%s %s' % (self.groupname, self.accounts)