Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#337 closed defect (fixed)

DateTime fields don't work in the generic views

Reported by: mlambert@… Owned by: jacob
Component: Generic views Version:
Severity: major Keywords: new-admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

fieldname_date and fieldname_time aren't set on the data dictionary, so the form fields come up blank

And similarly, jacobkm said that this also needs the server to recombine these fields back into plain old fieldname on the POST-side.

Attachments (1)

cu.diff (876 bytes) - added by mlambert@… 9 years ago.
diff that fixes #337 and #338

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by mr_little

Look at admin-pages head, and add to generic templates html head necessary javascripts from admin media

comment:2 Changed 10 years ago by mlambert@…

I don't quite know what you mean in the above comment, mr_little. I don't believe it's an issue of javascript. I believe this is because _get_flattened_data is only called for admin views, and the code needs to run for generic views as well., to set up fieldname_date and fieldname_time.

comment:3 Changed 10 years ago by anonymous

Please fix soon. Very frustrating that the fields are not updated.

comment:4 Changed 10 years ago by jacob

  • Component changed from Template system to Generic views
  • Owner changed from adrian to jacob
  • Status changed from new to assigned

comment:5 Changed 9 years ago by deltabps

  • Severity changed from normal to major

Yes, please fix this soon. I try to get my view on the appropriate code, perhaps I could help.

This is a show-stopper for my django project :(

comment:6 Changed 9 years ago by mlambert@…

So the quick hack-fix for this is:

In views/generic/create_update.py, in the big else statement for the request.POST check, after "new_data = object.dict", add:

from django.views.admin.main import _get_mod_opts, _get_flattened_data
mod, opts = _get_mod_opts(app_label, module_name)
for f in opts.fields:

new_data.update(_get_flattened_data(f, getattr(object, f.column)))

Basically, a c&p of the code from the admin interface to use the functions that we need in the generic views. I'm keeping this simple fix until the django developers get around to implemeting a more proper fix (involving code reorganization and such to avoid generic views' reliance on admin stuff)

Changed 9 years ago by mlambert@…

diff that fixes #337 and #338

comment:7 Changed 9 years ago by jacob

  • milestone set to Version 1.0

comment:8 Changed 9 years ago by rjwittams

  • Keywords new-admin added

This is fixed in new-admin

comment:9 Changed 9 years ago by rjwittams

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

fixed in new-admin merge . People still have to manually include javascript.

comment:10 Changed 8 years ago by anonymous

  • milestone Version 1.0 deleted

Milestone Version 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top