2010-01-27 15:48:09 +00:00
|
|
|
from django.db.models import ForeignKey, ManyToManyField
|
|
|
|
|
|
2012-01-11 20:22:29 +00:00
|
|
|
from .models import Category
|
2011-03-17 10:20:53 +00:00
|
|
|
|
2012-07-12 23:24:55 +00:00
|
|
|
|
2010-01-27 15:48:09 +00:00
|
|
|
class CategoryM2MField(ManyToManyField):
|
|
|
|
|
def __init__(self, **kwargs):
|
2011-03-17 10:20:53 +00:00
|
|
|
if 'to' in kwargs:
|
|
|
|
|
kwargs.pop('to')
|
2010-01-27 15:48:09 +00:00
|
|
|
super(CategoryM2MField, self).__init__(to=Category, **kwargs)
|
2010-02-12 17:09:58 +00:00
|
|
|
|
|
|
|
|
|
2010-01-27 15:48:09 +00:00
|
|
|
class CategoryFKField(ForeignKey):
|
|
|
|
|
def __init__(self, **kwargs):
|
2011-03-17 10:20:53 +00:00
|
|
|
if 'to' in kwargs:
|
|
|
|
|
kwargs.pop('to')
|
|
|
|
|
super(CategoryFKField, self).__init__(to=Category, **kwargs)
|
2011-05-08 00:33:00 +00:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from south.modelsinspector import add_introspection_rules
|
|
|
|
|
add_introspection_rules([], ["^categories\.fields\.CategoryFKField"])
|
|
|
|
|
add_introspection_rules([], ["^categories\.fields\.CategoryM2MField"])
|
|
|
|
|
except ImportError:
|
|
|
|
|
pass
|