Hi, but position? is no self.position? Brandon Taylor escribió: > Hi everyone, > > I want to add an integer field to a table callled "position" to do > ordering by. I would like the field to auto-increment based on the > count of objects. > > I've tried overriding the save() method of the model, but this doesn't > seem to work with the admin. > > Here's some simple test code for my model: > > class Link(models.Model): > friendly_name = models.CharField(max_length=100) > url = models.URLField('Website Address', verify_exists=True, > help_text='Ener the full URL, including http://') > position = models.PositiveSmallIntegerField(editable=False) #to > hide in admin > > def __unicode__(self): > return self.friendly_name > > def save(self): > position = 1 > super(Link, self).save() > > class Admin: > pass > > > That should just make the position column = 1, but I get an error > saying that "position" can't be null. Advice appreciated! > > Thanks, > Brandon > > > >
-- ------------------------------------------------------------------- Tomás Garzón Hervás Director de Desarrollo y Calidad IACTIVE Intelligent Solutions, S.L. -- Teléfono Móvil: 646760508 -- Bussines & Innovation Center (BIC) Parque tecnológico de ciencias de la salud Avd. de la innovación 1 C.P. 18100 Armilla (Granada) ------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---