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()}),
)
On Thursday, December 5, 2013 7:33:52 PM UTC+4, Lasha Gogua wrote:
>
> i use django 1.2 e-commerce and don't description views.py (((
>
> On Thursday, December 5, 2013 4:50:57 PM UTC+4, Sergiy Khohlov wrote:
>>
>> Send a view.py and urls.py
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>>
>> On Thu, Dec 5, 2013 at 8:21 AM, Lasha Gogua <[email protected]> wrote:
>>
>>> help me please...
>>>
>>> TypeError at /admin/myshop/catalogcategory/add/
>>>
>>> 'NoneType' object has no attribute '__getitem__'
>>>
>>> Request Method:POSTRequest URL:
>>> http://127.0.0.1:8000/admin/myshop/catalogcategory/add/?_popup=1 Django
>>> Version:1.5Exception Type: TypeErrorException 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/pythonPython
>>> 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)
>>>
>>>
>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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.
>>>
>>
>>
--
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 [email protected].
To post to this group, send email to [email protected].
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/c73f486f-ccd5-437a-be1b-b2423132535c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.