django add catalog category typeerror

73 views
Skip to first unread message

Lasha Gogua

unread,
Dec 5, 2013, 1:21:47 AM12/5/13
to django...@googlegroups.com
help me please...

TypeError at /admin/myshop/catalogcategory/add/

'NoneType' object has no attribute '__getitem__'
Request Method:POST
Request URL:http://127.0.0.1:8000/admin/myshop/catalogcategory/add/?_popup=1
Django Version:1.5
Exception Type:TypeError
Exception Value:
'NoneType' object has no attribute '__getitem__'
Exception Location:/root/Dev/project/local/lib/python2.7/site-packages/django/contrib/admin/models.py in log_action, line 18
Python Executable:/root/Dev/project/bin/python
Python Version:2.7.3
---------------------------------------------------------------------------------------------------

models.py

 
from django.db import models

class Catalog(models.Model):
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=150)
    publisher = models.CharField(max_length=300)
    description = models.TextField()
    pub_date = models.DateTimeField('date published')

class CatalogCategory(models.Model):
    catalog = models.ForeignKey(Catalog, related_name='categories')
    parent = models.ForeignKey('self', blank=True, null=True, related_name='children')
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255, unique=True)
    description = models.TextField(blank=True)
    date = models.DateTimeField('date published')
    def __unicode__(self):
        if self.parent:
            return u'%s: %s - %s' % (self.catalog.name, self.parent.name,self.name)
            return u'%s: %s' % (self.catalog.name, self.name)

class Product(models.Model):
    category = models.ForeignKey(CatalogCategory, related_name='products')
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    description = models.TextField()
    photo = models.ImageField(upload_to='product_photo', blank=True)
    manufacturer = models.CharField(max_length=255, blank=True)
    price_in_dollars = models.DecimalField(max_digits=6,decimal_places=2)


class ProductAttribute(models.Model):
    name = models.CharField(max_length=300)
    description = models.TextField(blank=True)

    def __unicode__(self):
        return u'%s' % (self.name)

class ProductDetail(models.Model):
    product = models.ForeignKey(Product, related_name='details')
    attribute = models.ForeignKey(ProductAttribute)
    value = models.CharField(max_length=500)
    description = models.TextField(blank=True)

    def __unicode__(self):
        return u'%s: %s - %s' % (self.product, self.attribute, self.value)


Sergiy Khohlov

unread,
Dec 5, 2013, 7:50:57 AM12/5/13
to django-users
 Send  a view.py and urls.py 

Many thanks,

Serge


+380 636150445
skype: skhohlov


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8c8228ed-893d-455e-aad1-06063973cfbf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lasha Gogua

unread,
Dec 5, 2013, 10:33:52 AM12/5/13
to django...@googlegroups.com
i use django 1.2 e-commerce and don't description views.py (((

Lasha Gogua

unread,
Dec 5, 2013, 10:45:47 AM12/5/13
to django...@googlegroups.com
urls.py 

from django.conf.urls import patterns, include, url
from django.views.generic import ListView, DetailView
from myshop.models import *


urlpatterns = patterns('django.views.generic.list_detail',

    url(r'^product/$', 'object_list', {'queryset':Product.objects.all()}),
    url(r'^product/(?P<slug>[-\w]+)/$', 'object_detail', {'queryset':Product.objects.all()}),
)
Reply all
Reply to author
Forward
0 new messages