On Sat, May 14, 2011 at 9:10 PM, Korobase <boyee...@gmail.com> wrote:

>
>
> 2011/5/15 Andy McKay <a...@clearwind.ca>
>
>>
>> > Exception Type: TypeError at /admin/main/learndjango/add/
>> > Exception Value: 'float' object is not callable
>>
>>
>> Please paste your model that is having the problem.
>>
>
> class MyItem(models.Model):
>     title=models.CharField(max_length=1024)
>     description=models.CharField(max_length=1024)
>     price=models.FloatField(default=0.0)
>     time=models.DateTimeField()
>     name=models.CharField(max_length=256)
>     detail=models.CharField(max_length=1024)
>     address_city=models.CharField(max_length=36)
>     address_area=models.CharField(max_length=36)
>
>
>     def __unicode__(self):
>         return self.title
>
> and the ModelAdmin:
>
> class MyItemAdmin(admin.ModelAdmin):
>     list_display=('name','title','price','address_city',)
>
> admin.site.register(MyItem, MyItemAdmin)
>
>
>
The traceback indicates that the new object being added is not an instance
of MyItem, but rather a simple float. How that has happened is a mystery; it
is not due to anything you have posted so far. If you cut-and-paste just the
model and model admin definitions you show here into a new 1.3 project, the
admin works fine to add items. There is something more to your code that you
have not shown yet that is causing the problem. Really, Django can insert
float data into a MySQL table (although as Andy notes, using a float field
for something named "price" is likely really really really not what you want
to be doing.

Karen
-- 
http://tracey.org/kmt/

-- 
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.

Reply via email to