Opened 15 years ago

Closed 15 years ago

Last modified 13 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: no UI/UX: no


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@… 15 years ago.
diff that fixes #337 and #338

Download all attachments as: .zip

Change History (11)

comment:1 Changed 15 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 15 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 15 years ago by anonymous

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

comment:4 Changed 15 years ago by Jacob

Component: Template systemGeneric views
Owner: changed from Adrian Holovaty to Jacob
Status: newassigned

comment:5 Changed 15 years ago by deltabps

Severity: normalmajor

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 15 years ago by mlambert@…

So the quick hack-fix for this is:

In views/generic/, 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 15 years ago by mlambert@…

Attachment: cu.diff added

diff that fixes #337 and #338

comment:7 Changed 15 years ago by Jacob

milestone: Version 1.0

comment:8 Changed 15 years ago by rjwittams

Keywords: new-admin added

This is fixed in new-admin

comment:9 Changed 15 years ago by rjwittams

Resolution: fixed
Status: assignedclosed

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

comment:10 Changed 13 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

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