mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
Fixed auto_now_add weird editable behaviour.
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1244 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
69006c3721
commit
11a4288a08
Binary file not shown.
Binary file not shown.
@ -210,6 +210,7 @@ def items_for_result(cl, result):
|
||||
if first: # First column is a special case
|
||||
first = False
|
||||
url = cl.url_for_result(result)
|
||||
result_id = getattr(result, pk)
|
||||
yield ('<th%s><a href="%s"%s>%s</a></th>' % \
|
||||
(row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr))
|
||||
else:
|
||||
|
@ -109,6 +109,7 @@ class FormWrapper:
|
||||
|
||||
def __getitem__(self, key):
|
||||
for field in self.manipulator.fields:
|
||||
|
||||
if field.field_name == key:
|
||||
data = field.extract_data(self.data)
|
||||
return FormFieldWrapper(field, data, self.error_dict.get(field.field_name, []))
|
||||
@ -117,8 +118,7 @@ class FormWrapper:
|
||||
for inline_collection in self._inline_collections:
|
||||
if inline_collection.name == key:
|
||||
return inline_collection
|
||||
|
||||
raise KeyError
|
||||
raise KeyError("Could not find Formfield or InlineObjectCollection named:%s" % key )
|
||||
|
||||
def fill_inline_collections(self):
|
||||
if not self._inline_collections:
|
||||
|
@ -402,6 +402,13 @@ class DateField(Field):
|
||||
return datetime.datetime.now()
|
||||
return value
|
||||
|
||||
# Needed because of horrible auto_now[_add] behaviour wrt. editable
|
||||
def get_follow(self, override=None):
|
||||
if override != None:
|
||||
return override
|
||||
else:
|
||||
return self.editable or self.auto_now or self.auto_now_add
|
||||
|
||||
def get_db_prep_save(self, value):
|
||||
# Casts dates into string format for entry into database.
|
||||
if value is not None:
|
||||
@ -860,9 +867,7 @@ class BoundFieldLine(object):
|
||||
for bound_field in self.bound_fields:
|
||||
yield bound_field
|
||||
|
||||
def __repr__(self):
|
||||
return "%s:(%s)" % (self.__class__.__name__, self.bound_fields)
|
||||
|
||||
|
||||
def __len__(self):
|
||||
return len(self.bound_fields)
|
||||
|
||||
@ -881,7 +886,7 @@ class FieldLine(object):
|
||||
yield field
|
||||
|
||||
def __len__(self):
|
||||
return len(self.fields)
|
||||
return len(self.fields)
|
||||
|
||||
class BoundFieldSet(object):
|
||||
def __init__(self, field_set, field_mapping, original, bound_field_line_class=BoundFieldLine):
|
||||
@ -889,9 +894,7 @@ class BoundFieldSet(object):
|
||||
self.classes = field_set.classes
|
||||
self.bound_field_lines = [ field_line.bind(field_mapping,original, bound_field_line_class)
|
||||
for field_line in field_set]
|
||||
def __repr__(self):
|
||||
return "%s:(%s,%s)" % (self.__class__.__name__, self.name, self.bound_field_lines)
|
||||
|
||||
|
||||
def __iter__(self):
|
||||
for bound_field_line in self.bound_field_lines:
|
||||
yield bound_field_line
|
||||
|
@ -826,7 +826,6 @@ class DebugNodeList(NodeList):
|
||||
e.source = node.source
|
||||
raise
|
||||
except Exception, e:
|
||||
|
||||
from traceback import extract_tb, format_list, format_exception_only
|
||||
from sys import exc_info
|
||||
t,v,tb = exc_info()
|
||||
|
Loading…
x
Reference in New Issue
Block a user