A extendable category app using django-mptt for django-shop
Project description
A extendable category app using django-mptt for django-shop.
Installation
For the current stable version:
pip install django-shop-categories
For the development version:
pip install -e git+git://github.com/fivethreeo/django-shop-categories.git#egg=django-shop-categories
Running tests:
git clone git://github.com/fivethreeo/django-shop-categories.git cd django-shop-categories virtualenv test_env source ./test_env/bin/activate pip install -r requirements.txt python runtests.py
Configuration
Add shop_categories 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 syncdb
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
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 syncdb
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 django-shop-categories can be found here: https://github.com/fivethreeo/django-shop-example
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-shop-categories-0.8.beta.3.zip
.
File metadata
- Download URL: django-shop-categories-0.8.beta.3.zip
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ccf59cf5b5040a42786c1dd0eaf92a3b4212ec0ae14ce08650dc36ccd9955fe |
|
MD5 | c663572f9fe597cff7ea0f400bc05c15 |
|
BLAKE2b-256 | 4805386c38887b88ffb837cbd44555fce1bcbdd176accefeb4777c2b689a49fb |