Giter Club home page Giter Club logo

django-shop-categories's Introduction

django-shop-categories

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

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

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 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 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, '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 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

django-shop-categories's People

Contributors

fivethreeo avatar iamit avatar airtonix avatar winxton avatar clincher avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.