coercing to Unicode Django -
i'm building sample django application collects few input products , picture..
i have integrated product model forms , trying add new products through django admin...
i following error, when try create new product..
error:
typeerror @ /admin/catalog/product/add/ coercing unicode: need string or buffer, tuple found request method: post request url: http://127.0.0.1:8000/admin/catalog/product/add/ django version: 1.4.3 exception type: typeerror exception value: coercing unicode: need string or buffer, tuple found exception location: c:\python27\lib\ntpath.py in abspath, line 471
code:
models.py
class product(models.model): name = models.charfield(max_length=255,unique=true) slug = models.slugfield(max_length=255,unique=true,help_text="unique value product page url, created name.") brand = models.charfield(max_length=50) sku = models.charfield(max_length=50) price = models.decimalfield(max_digits=9,decimal_places=2) old_price = models.decimalfield(max_digits=9,decimal_places=2,blank=true,default=0.00) #image = models.charfield(max_length=50) is_active = models.booleanfield(default=true) is_bestseller = models.booleanfield(default=false) is_featured = models.booleanfield(default=false) quantity = models.integerfield() description = models.textfield() meta_keywords = models.charfield(max_length=255,help_text="comma-delimited set of seo keywords meta tag") meta_description = models.charfield(max_length=255,help_text="content description meta tag") created_at = models.datetimefield(auto_now_add=true) updated_at = models.datetimefield(auto_now=true) categories = models.manytomanyfield(category) image = models.imagefield(upload_to='images/products/main') thumbnail = models.imagefield(upload_to='images/products/thumbnails') image_caption = models.charfield(max_length=200) class meta: db_table = 'products' ordering = ['-created_at'] def __unicode__(self): return self.name @models.permalink def get_absolute_url(self): return ('catalog_product',(),{'product_slug':self.slug}) @property def sale_price(self): if self.old_price > self.price: return self.price else: return none
settings.py
media_root = "static/",
request object:
get no data post variable value sku u'239' meta_description u'iphone' meta_keywords u'iphone' name u'apple iphone' _save u'save' is_active u'on' price u'239' description u'iphone' old_price u'200' slug u'apple_iphone' image_caption u'phone' csrfmiddlewaretoken u'suo3uq5sfz0bo153cxicixpcmnv5hhsn' brand u'apple' categories u'1' quantity u'1' files variable value image <inmemoryuploadedfile: snip.png (image/png)> thumbnail <inmemoryuploadedfile: snip.png (image/png)>
is there problem uploading png file in image object?
Comments
Post a Comment