Skip to main content

A extendable category app using django-mptt for django-shop

Project description

A extendable category app using django-mptt for django-shop.

https://travis-ci.org/lanshark/ls-django-shop-categories.png?branch=develop

Installation

For the current stable version:

pip install ls-django-shop-categories

For the development version:

pip install -e git+git://github.com/lanshark/ls-django-shop-categories.git#egg=ls-django-shop-categories

Running tests:

git clone git://github.com/lanshark/ls-django-shop-categories.git
cd ls-django-shop-categories
virtualenv test_env
source ./test_env/bin/activate
pip install -r requirements.txt
python develop.py test

Configuration

Add shop_categories and treeadmin to settings.INSTALLED_APPS.

Set SHOP_PRODUCT_MODEL to shop_categories.models.defaults.product.default.CategoryProduct.

In your urls.py add this before your shop patterns:

urlpatterns += patterns('',
    url(r'^catalog/', include('shop_categories.urls')),
)

Then run:

manage.py migrate

Extending the Category model

In your own app make a models dir with __init__.py and a category.py dir, like so:

app/models/__init__.py
app/models/category.py

Note: Do not import the model from category.py in __init__.py, the model should NOT be in a “real” models module as this will cause the overridden Category model to be defined twice.

In category.py:

from django.db import models
from shop_categories.models.defaults.category.base import ProductCategoryBase

class Category(ProductCategoryBase):

    image = models.ImageField(upload_to='categoryimages/', null=True, blank=True)

    class Meta:
        abstract = False
        app_label = 'app'

Set SHOP_CATEGORIES_CATEGORY_MODEL to ('app.models.category.Category, 'app')

Register your custom category model in admin.py:

from shop_categories.models import Category
from shop_categories.admin import ProductCategoryAdmin

admin.site.register(Category, ProductCategoryAdmin)

Then, assuming your Product model is not already synced, run:

manage.py migrate

Extending the Product model

When extending Product models in your shop make sure they subclass from shop_categories.models.defaults.product.base.CategoryProductBase to add the Category Foreignkey and M2M fields.

Example implementation

An example of a django-shop with ls-django-shop-categories can be found here: https://github.com/lanshark/ls-django-shop-example

1.0.4

Updated dependencies

1.0.3

Updated default Boolean fields

1.0.2

Updated dependencies for ls-django-treeadmin

1.0.1

Forked, Renamed, Updated By Scott Sharkey Added compatibility with Django 1.7+, and eventually Python 3

1.0

Last release by original author

Project details


Release history Release notifications

This version
History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ls-django-shop-categories-1.0.4.tar.gz (7.8 kB) Copy SHA256 hash SHA256 Source None Jan 4, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page