model inheritance and column ordering
Is there a way to specify a field in an abstract base class, but have the corresponding column appear last in the table's column list? class A(models.Model): ts = models.DateTimeField(default=datetime.now()) class Meta: abstract = True class B(A): blah = CharField() I'd like the 'ts' column to come after the 'blah' column. I see that there is some notion of ordering in the models documentation, but somehow I don't see how to accomplish this. Thanks for the help. --~--~-~--~~~---~--~~ 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: model inheritance and column ordering
Thanks for the reply. There's no real problem. I just want the audit columns to appear after the more important ones if I'm looking at the db. I guess it's a matter of readability. On Apr 8, 11:04 am, Malcolm Tredinnick wrote: > On Tue, 2009-04-07 at 19:30 -0700, rvr wrote: > > Is there a way to specify a field in an abstract base class, but have > > the corresponding column appear last in the table's column list? > > > class A(models.Model): > > ts = models.DateTimeField(default=datetime.now()) > > class Meta: > > abstract = True > > > class B(A): > > blah = CharField() > > > I'd like the 'ts' column to come after the 'blah' column. I see that > > there is some notion of ordering in the models documentation, but > > somehow I don't see how to accomplish this. Thanks for the help. > > No, there's no way. What's the real problem are you actually trying to > solve here? Column ordering is almost always completely irrelevant, > since they are sets of values, not ordered collections. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
setting a model field to null
How can I set a model field to null after it has had a non-null value? -- class Blah(models.Model): foo = models.IntegerField(null=True) blah = Blah() blah.foo = 5 # now set it to null blah.foo = ??? -- None doesn't seem to work and I don't seem to be able to figure this out from the documentation. Thanks for your help. ~rvr --~--~-~--~~~---~--~~ 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: setting a model field to null
Obviously I misread something. None works perfectly. Thanks very much. On Apr 16, 3:05 pm, Margie wrote: > blah.foo = None should do the trick > > On Apr 15, 8:01 pm, rvr wrote: > > > > > How can I set a model field to null after it has had a non-null value? > > > -- > > class Blah(models.Model): > > foo = models.IntegerField(null=True) > > > blah = Blah() > > blah.foo = 5 > > > # now set it to null > > blah.foo = ??? > > -- > > > None doesn't seem to work and I don't seem to be able to figure this > > out from the documentation. Thanks for your help. > > > ~rvr --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---