Code

Ticket #1683: base.py.diff

File base.py.diff, 801 bytes (added by iki, 8 years ago)
Line 
1Index: django/db/models/base.py
2===================================================================
3--- django/db/models/base.py    (revision 2747)
4+++ django/db/models/base.py    (working copy)
5@@ -105,6 +105,11 @@
6                 else:
7                     val = kwargs.pop(f.attname, f.get_default())
8                     setattr(self, f.attname, val)
9+            for prop in kwargs.keys():   # keys has to be a copy
10+                try:
11+                    if isinstance(getattr(self.__class__, prop), property):
12+                        setattr(self, prop, kwargs.pop(prop))
13+                except AttributeError: pass
14             if kwargs:
15                 raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0]
16         for i, arg in enumerate(args):