On Dec 21, 2007 10:05 AM, Gio <[EMAIL PROTECTED]> wrote: > Hi all, > I'm writing a custom field wishing to implement something similar to a > multiplechoice. > The problem is that when I run syncdb I receive a > AttributeError: 'ListField' object has no attribute 'db_column' > Any idea?
I didn't get through all of your code, but I did find one fairly severe problem that's probably causing your error, so I stopped there. > class ListField(models.Field): > __metaclass__ = models.SubfieldBase > > > def __init__(self, *args, **kwargs): > self.separator = kwargs['separator'] > # checking if separator has been carefully chosen > for choice in kwargs['choices']: > if self.separator in choice[0]: > # separator is a character already present in choices, this cannot be > raise TypeError('Separator colliding with choices, see > choice \'%s\'.' % choice[0]) > > kwargs['max_length'] = 255 Don't forget, you *must* call __init__ on the base class in order to get all the good stuff. Add the following line at the end of your __init__ method: super(ListField, self).__init__(*args, **kwargs) Of course, that will probably cause you another error, because you left "separator" in kwargs. You'll also probably want to change your first line there to this: self.separator = kwargs.pop('separator') That way, it gets removed from kwargs along the way, so it won't cause problems with the __init__ method of the base class. -Gul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---