From 29ab0943c5b67240d0ed0271b4efd2d947ad497b Mon Sep 17 00:00:00 2001 From: Martin Ogden Date: Thu, 17 Mar 2011 18:20:53 +0800 Subject: [PATCH] Remove 'to' from kwargs in CategoryM2MField and CategoryFKField. 'to' is already specified, and causes errors when running unit tests --- categories/fields.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/categories/fields.py b/categories/fields.py index 21ba41a..f2cdb00 100644 --- a/categories/fields.py +++ b/categories/fields.py @@ -1,12 +1,18 @@ from django.db.models import ForeignKey, ManyToManyField +from categories.models import Category + + + class CategoryM2MField(ManyToManyField): def __init__(self, **kwargs): - from categories.models import Category + if 'to' in kwargs: + kwargs.pop('to') super(CategoryM2MField, self).__init__(to=Category, **kwargs) class CategoryFKField(ForeignKey): def __init__(self, **kwargs): - from categories.models import Category - super(CategoryFKField, self).__init__(to=Category, **kwargs) \ No newline at end of file + if 'to' in kwargs: + kwargs.pop('to') + super(CategoryFKField, self).__init__(to=Category, **kwargs)