List Info

Thread: Field default values don't seem to work as expected




Field default values don't seem to work as expected
country flaguser name
United States
2007-02-27 10:28:50
If I have the given model in an app:

class Product(models.Model):
	name = models.CharField(maxlength=150)
	list_price = models.FloatField(max_digits=10,
decimal_places=2, 
default=0.00, blank=True)
	price = models.CharField(max_digits=10, decimal_places=2)
	
	class Admin:
		pass

When adding a new product through the admin site you will
get an 
IntegrityError? saying that list_price may not be NULL. I
have tested 
this with MySQL and SQLite and both result in this error.
While I could 
change the value on the fly before saving the object, but
the default 
parameter would seem like it should handle that for me.  Is
my belief 
that the default parameter of the field should be inserting
0.00 
instead of None (which is turned into NULL) correct?

Brian



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )