Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed stuff

  • Loading branch information...
commit 670baa4e2a96e783053e6dafd0ee12c9743e1549 1 parent 741b1da
@seanbrant seanbrant authored
Showing with 7 additions and 9 deletions.
  1. +2 −5 filch/fields.py
  2. +5 −4 filch/tests/tests.py
View
7 filch/fields.py
@@ -24,7 +24,7 @@ def __get__(self, instance, owner):
"or json formated array. You passed in %s" % items)
# We iterate over the items and only return the values
# not the keys.
- return [v for k, v in instance.__dict__[self.field.name]]
+ return instance.__dict__[self.field.name]
def __set__(self, instance, value):
instance.__dict__[self.field.name] = value
@@ -84,7 +84,7 @@ def _update(self, **kwargs):
return
objects = getattr(self.current_instance, self.from_field).all()
- items = [[o.pk, self._prepare(o)] for o in objects]
+ items = [self._prepare(o) for o in objects]
self.current_instance.__dict__[self.name] = dumps(items)
self.current_instance.__class__.objects \
@@ -92,7 +92,6 @@ def _update(self, **kwargs):
.update(**{self.name: self.current_instance.__dict__[self.name]})
def _connect(self, instance, **kwargs):
-
# We need to access the from_field from the class
# otherwise we get the many-to-many descriptor
# which throws a primary key error.
@@ -127,5 +126,3 @@ def south_field_triple(self):
field_class = "django.db.models.fields.TextField"
args, kwargs = introspector(self)
return (field_class, args, kwargs)
-
-
View
9 filch/tests/tests.py
@@ -64,19 +64,20 @@ def test_related_instance_update(self):
self.assertEquals(self.person.group_list, [])
def test_main_model_update_error(self):
- # fake create step
person = Person.objects.create(name='Sean')
person.save()
person.groups.add(self.group1)
person.groups.add(self.group2)
- print person.group_list
- # fake update step
+ person.save()
+ self.assertEquals(person.group_list, [{'name': 'PyChi', 'location': {'name': 'Chicago'}}, {'name': 'WhiteSoxsFan', 'location': {'name': 'Chicago'}}])
person = Person.objects.get(id=person.id)
+ person.name = 'Matt'
person.save()
person.groups.clear()
person.groups.add(self.group1)
person.groups.add(self.group2)
- print person.group_list # this should fail
+ person.save()
+ self.assertEquals(person.group_list, [{'name': 'PyChi', 'location': {'name': 'Chicago'}}, {'name': 'WhiteSoxsFan', 'location': {'name': 'Chicago'}}])
class GenericResolutionManagerTestCase(TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.