Re: Newbe DateTimeField Question
On Sun, Aug 21, 2011 at 12:33 PM, Torstenwrote: > Hi > > I simply want the DateTime to be set to null. > > payed_at = models.DateTimeField(null=True) > > but always get this as an error: > > IntegrityError at /admin/invoice/invoice/add/ > invoice_invoice.payed_at may not be NULL > > > Thanks for help. > > Torsten > IntegrityError comes from the database, so django was happy with having payed_at=None, but your database wasn't. I suspect you added null=True to your model after having run syncdb, and the database table does not reflect the model. Remember that syncdb does not modify tables that already exist, or validate that they match their corresponding models. Cheers Tom -- 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: Newbe DateTimeField Question
Thanks for that, but I still get the error message: Exception Type: IntegrityError Exception Value:invoice_invoice.payed_at may not be NULL here my models.py: from django.db import models class Customer(models.Model): company = models.CharField(max_length=255) branch = models.CharField(max_length=255) firstname = models.CharField(max_length=255) lastname = models.CharField(max_length=255) street = models.CharField(max_length=255) zip = models.CharField(max_length=6) country = models.CharField(max_length=255) email = models.CharField(max_length=255) created_at = models.DateTimeField('date created') def __unicode__(self): return self.company class Project(models.Model): title = models.CharField(max_length=255); created_at = models.DateTimeField('date created') def __unicode__(self): return self.title class Invoice(models.Model): customer = models.ForeignKey(Customer) project = models.ForeignKey(Project, null=True) sum = models.FloatField(default=0) tax = models.IntegerField(default=16) payed_at = models.DateTimeField(default=None) payable_at = models.DateField('payable at') created_at = models.DateTimeField(False, True) class InvoiceItem(models.Model): invoice = models.ForeignKey(Invoice) text = models.TextField() unit = models.CharField(max_length=255) amount = models.IntegerField() sum = models.FloatField() On 21 Aug., 15:19, dm03514wrote: > you can set default=None, that way you don't have to explicityly save > that value as none every time you save an object. > > On Aug 21, 7:33 am, Torsten wrote: > > > > > > > > > Hi > > > I simply want the DateTime to be set to null. > > > payed_at = models.DateTimeField(null=True) > > > but always get this as an error: > > > IntegrityError at /admin/invoice/invoice/add/ > > invoice_invoice.payed_at may not be NULL > > > Thanks for help. > > > Torsten -- 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: Newbe DateTimeField Question
you can set default=None, that way you don't have to explicityly save that value as none every time you save an object. On Aug 21, 7:33 am, Torstenwrote: > Hi > > I simply want the DateTime to be set to null. > > payed_at = models.DateTimeField(null=True) > > but always get this as an error: > > IntegrityError at /admin/invoice/invoice/add/ > invoice_invoice.payed_at may not be NULL > > Thanks for help. > > Torsten -- 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.
Newbe DateTimeField Question
Hi I simply want the DateTime to be set to null. payed_at = models.DateTimeField(null=True) but always get this as an error: IntegrityError at /admin/invoice/invoice/add/ invoice_invoice.payed_at may not be NULL Thanks for help. Torsten -- 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.