Re: Error when subclassing models.ForeignKey field
On 26 Jan., 18:33, Roman Kleselwrote: > Should I open a bug report? That's what I just did: http://code.djangoproject.com/ticket/15184 -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error when subclassing models.ForeignKey field
Hello again, since no one responded untill now, I'd like to bring this back to attention. If no one knows an answer to my question, maybe some one could give me some hint what I could do? Should I open a bug report? Thanks in advance! Roman -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Error when subclassing models.ForeignKey field
Hello, I'm using a current SVN checkout of django an I'm having difficulties creating a custom field. class ForeignKeyAX(models.ForeignKey): __metaclass__ = models.SubfieldBase description = "ForeignKey field prepared for Ajax Autocompletion" def __init__(self,*args,**kwargs): self.kunde_rel=False if kwargs.has_key('kunde_rel'): self.kunde_rel = kwargs.pop('kunde_rel') super(ForeignKeyAX, self).__init__(*args,**kwargs) with this, I get the folowing error: KeyError at /path//id/ 'ip' Request Method: GET Request URL:http://localhost:8000/path/id/ Django Version: 1.3 beta 1 SVN-15308 Exception Type: KeyError Exception Value: 'ip' Exception Location: /path-to_djanog/django/db/models/fields/subclassing.py in __get__, line 96 and further down: /home/roman/devel/django-trunk/django/db/models/fields/subclassing.py in __get__ 89. def __init__(self, field): self.field = field def __get__(self, obj, type=None): if obj is None: raise AttributeError('Can only be accessed via an instance.') 96. return obj.__dict__[self.field.name] 'ip' is not contained in obj.__dict__. Like the other foreignkey fields its there as ip_id. What am I doing wrong? How can I get this going? BTW: When I ommit the line: __metaclass__ = models.SubfieldBase Everything works fine. But then other things I want to do like overriding to_python will not work as far as I understand. Please help. Best regards Roman -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: subclassing a Field
You cannot add custom database field types without altering the db backend code. On 31 Jan, 09:58, Antonio <[EMAIL PROTECTED]> wrote: > hi all, > > I've created a TYPE in PostgreSQL : > > Composite type "utente.datirim" > Column| Type > -+ > nome| text > turno | time without time zone > comandante | text > disormeggio | time without time zone > arrivo | time without time zone > fine| time without time zone > inizio | time without time zone > attracco| time without time zone > > I'm trying to create a new Field in Django to map a database table into a > model ... I've tryied to subclass Field, but I've got errors when I 'syncdb'. > > There's a tutorial about this procedure ?? It's possible ?? > > tanks in advance .. > > PS sorry for my english ... > > -- > #include > int main(void){char > c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110, > 101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101, > 116,46,105,116,62,10,10,0};printf("%s",c);return 0;} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
subclassing a Field
hi all, I've created a TYPE in PostgreSQL : Composite type "utente.datirim" Column| Type -+ nome| text turno | time without time zone comandante | text disormeggio | time without time zone arrivo | time without time zone fine| time without time zone inizio | time without time zone attracco| time without time zone I'm trying to create a new Field in Django to map a database table into a model ... I've tryied to subclass Field, but I've got errors when I 'syncdb'. There's a tutorial about this procedure ?? It's possible ?? tanks in advance .. PS sorry for my english ... -- #include int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110, 101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101, 116,46,105,116,62,10,10,0};printf("%s",c);return 0;} --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---