form._raw_value(fieldname) gone in Django 1.9

不打扰是莪最后的温柔 提交于 2019-12-06 14:32:37

问题


I have code which uses form._raw_value(fieldname).

This is gone in Django 1.9.

Is there a way to access the raw value in 1.9+?

Update

I am only migrating the code to Django 1.9. Up to now I have no deeper understanding of what's going on there in detail.


回答1:


Looking at the source code, the _raw_value method is only 3 lines long, so it would be easy to add it as a function to your code.

def _raw_value(form, fieldname):
    field = form.fields[fieldname]
    prefix = form.add_prefix(fieldname)
    return field.widget.value_from_datadict(form.data, form.files, prefix)

Then change your code from form._raw_value(fieldname) to _raw_value(form, fieldname).



来源:https://stackoverflow.com/questions/39348870/form-raw-valuefieldname-gone-in-django-1-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!