On Dec 1, 3:48 pm, ttw <[EMAIL PROTECTED]> wrote: > bit worrying that you consider the traceback to be 'gumph' ...
Gumph in the sense that it didn't seem awfully relevant in this case, as the exception was reasonably self-explanatory. I'm very grateful for Python's stack trace in other circumstances, though I've found that there are cases where Django magic seems to make the errors and the stack more confusing than I think they ought be. > the error says specifically that the 'created' column cannot be null, > it sounds like your DB and model are out of sync. I'd just done a manage.py flush, so I'm guessing DB vs model was all in order. > there are a couple of ways to munge the logic to make it work but i'm > sure you'll figure out what's best for your own scenario. My just-tried hack involves dumping the values of the Person object into the new User too. I'm surprised there isn't a more clean and correct way of doing it though, given that I'm probably going to cry any time I want to create a "created" field in the User table! Cheers anyhow! > On Nov 30, 1:24 pm, Fergus <[EMAIL PROTECTED]> wrote: > > > I have an inheritance system for defining people. > > > So there's a class Person, and sub-class User thus: > > > class Person(models.Model): > > ''' A person! ''' > > > firstname = models.CharField("first name", max_length = 128, > > help_text = "(required)") > > lastname = models.CharField("last name", max_length = 128, > > help_text = "(required)") > > email = models.EmailField("email address", unique = True, > > help_text = "(required)") > > groups = models.ManyToManyField(Group, blank = True, through = > > 'Membership', related_name = 'group_set', verbose_name = "group > > memberships") > > > created = models.DateTimeField(auto_now_add = True) > > last_modified = models.DateTimeField(auto_now = True) > > > class User(Person): > > ''' Persons who are also users ''' > > > password = models.CharField(max_length = 40, blank = True, > > editable = False) > > > I would like to add child classes after previously having an object as > > only a parent - so at some point in time a Person can become a User. > > So I try this in the manage.py shell: > > > >>> from MyPidge.Users.models import Person, User > > >>> myuser = Person.objects.create(firstname = "Fergus", lastname = > > >>> "Ferrier", email = "[EMAIL PROTECTED]") > > >>> myuser.save() > > > After myuser.save() there is a Person row in the DB, and all appears > > well. > > > >>> newu = User(password = "hello") > > >>> newu.person_ptr_id = myuser.id > > > [ also tried person = myuser and person_ptr = myuser]>>> newu.save() > > > ... Traceback gumph ... > > Warning: Column 'created' cannot be null > > > There is no User row, and the Person row now has blank values except > > for the last modified field. > > > Please tell me if I've done something totally crazy. I only want to > > add children after-the-fact... > > > Many thanks, > > Ferg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---