Ticket #17080: models.py

File models.py, 673 bytes (added by Paul Garner, 13 years ago)

A minimal test case

Line 
1from django.db import models
2from django.core import serializers
3
4
5class TestField(models.TextField):
6 def get_attname(self):
7 return '%s_attr' % self.name
8
9class TestModel(models.Model):
10 test = TestField()
11
12
13
14TestModel(test='blah')
15# TypeError: 'test' is an invalid keyword argument for this function
16
17TestModel(test_attr='blah')
18# <TestModel: TestModel object>
19
20
21test = TestModel(test_attr='blah')
22json = serializers.serialize('json', [test])
23# OK
24# json == '[{"pk": null, "model": "testapp.testmodel", "fields": {"test": "blah"}}]'
25
26[obj for obj in serializers.deserialize('json', json)]
27# TypeError: 'test' is an invalid keyword argument for this function
Back to Top