Code

Opened 6 years ago

Closed 6 years ago

#6185 closed (fixed)

FreeComment model breaks in admin

Reported by: Øyvind Saltvik <oyvind@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: nfa-blocker
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Traceback follows

Environment:

Request Method: GET
Request URL: http://emmet.cylon.no/admin/comments/freecomment/8/
Django Version: 0.97-newforms-admin-SVN-6914
Python Version: 2.4.3
Installed Applications: 
   ['emmet.conf',
 'emmet.emmetbase',
 'emmet.emmetpages',
 'emmet.emmetcontact',
 'emmet.emmettextileeditor',
 'emmet.emmetimages',
 'emmet.emmetregistration',
 'emmet.emmetgallery',
 'emmet.emmetfilearchive',
 'emmet.emmetnews',
 'tagging',
 'registration',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.admin',
 'comment_utils',
 'django.contrib.comments',
 'eucaliptus',
 'extensions']
Installed Middleware: 
   ('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Template error:
In template /home/emmet/code/django/contrib/admin/templates/admin/includes/fieldset.html, error at line 4
   Caught an exception while rendering: "Key 'submit_date' not found in Form"
   1 : <fieldset class="module aligned {{ fieldset.classes }}">


   2 :   {% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}


   3 :   {% if fieldset.description %}<div class="description">{{ fieldset.description }}</div>{% endif %}


   4 :    {% for line in fieldset %} 


   5 :       <div class="form-row{% if line.errors %} errors{% endif %} {% for field in line %}{{ field.field.name }} {% endfor %} ">


   6 :       {{ line.errors }}


   7 :       {% for field in line %}


   8 :           {% if field.is_checkbox %}


   9 :               {{ field.field }}{{ field.label_tag }}


   10 :           {% else %}


   11 :               {{ field.label_tag }}{{ field.field }}


   12 :           {% endif %}


   13 :           {% if field.field.field.help_text %}<p class="help">{{ field.field.field.help_text|safe }}</p>{% endif %}


   14 :       {% endfor %}


Traceback:
File "/home/emmet/code/django/template/__init__.py" in render_node
  822.             result = node.render(context)
File "/home/emmet/code/django/template/defaulttags.py" in render
  151.                 nodelist.append(node.render(context))
File "/home/emmet/code/django/template/defaulttags.py" in render
  241.                     value = bool_expr.resolve(context, True)
File "/home/emmet/code/django/template/__init__.py" in resolve
  579.             obj = self.var.resolve(context)
File "/home/emmet/code/django/template/__init__.py" in resolve
  720.             value = self._resolve_lookup(context)
File "/home/emmet/code/django/template/__init__.py" in _resolve_lookup
  755.                                 current = current()
File "/home/emmet/code/django/contrib/admin/options.py" in errors
  104.         return mark_safe(u'\n'.join([self.form[f].errors.as_ul() for f in self.fields]))
File "/home/emmet/code/django/newforms/forms.py" in __getitem__
  85.             raise KeyError('Key %r not found in Form' % name)

Exception Type: KeyError at /admin/comments/freecomment/8/
Exception Value: "Key 'submit_date' not found in Form"

Attachments (3)

r6898_comment_submit_date_fix.diff (695 bytes) - added by brosner 6 years ago.
workaround to a legacy comments app problem
frecomment_removed_auto_add_now.diff (1.1 KB) - added by Øyvind Saltvik <oyvind@…> 6 years ago.
auto add now sets editable=False removed it and set the submit_date in save
freecomments_newforms_fix.diff (767 bytes) - added by aleander@… 6 years ago.
Fix as suggested

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by brosner

  • Keywords nfa-blocker added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Just the copy and paste exception would have done ;) I have confirmed this. I will take a closer look a little later today.

comment:2 Changed 6 years ago by brosner

  • Keywords freecomment model breaks admin removed

Changed 6 years ago by brosner

workaround to a legacy comments app problem

Changed 6 years ago by Øyvind Saltvik <oyvind@…>

auto add now sets editable=False removed it and set the submit_date in save

comment:3 Changed 6 years ago by Øyvind Saltvik <oyvind@…>

  • Has patch set

comment:4 Changed 6 years ago by brosner

Øyvind,

Your patch is correcting the right problem, but it would be a better patch to just use default=datetime.datetime.now instead of overriding the save method.

Changed 6 years ago by aleander@…

Fix as suggested

comment:5 Changed 6 years ago by aleander@…

Well, this seems to work.

comment:6 Changed 6 years ago by brosner

  • Resolution set to fixed
  • Status changed from new to closed

(In [7211]) newforms-admin: Fixed #6185. Removed submit_date from FreeComment ModelAdmin as it is not an editable field.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.