Passing and retrieving context data to and from form

Hi. I’m very new to Django, and still learning. I’ve been trying to figure out how to do something that’s probably pretty straightforward. So I’d appreciate it if someone could point me in the right direction.

I have a page that displays a table. The user can select a row and request to edit it. When this happens, I display a form with fields for the various columns. The fields that correspond to the row’s key are disabled, and the others are editable.

The problem I’m having is how to retrieve the data in those disabled fields after the form is submitted. I need that so that I can tell the database what key the new values are associated with. It seems that Django only passes back the editable fields. (It all works fine if I make those fields editable). I’ve tried adding this data to the context that’s passed into the form, and then adding that as a query parameter to the return URL, but that seems to be ignored, perhaps because it’s a POST.

This seems to be a pretty generic task, so there’s presumably a simple solution to it. I don’t know of any place other than the form where I could remember this data. Can I add the data to the HTML somewhere so that it will be passed back to me as part of the POST? Or is there just a completely different way of handling this?

One last thing. I am not using a Model for this, because the interface to the database is a webservice rather than talking to it directly with SQL, and it seemed that Models only handle SQL.I don’t know if that impacts how the problem might be addressed.

Anyway, any suggestions would be greatly appreciated. Thanks.

That’s not Django doing that, that’s an HTML standard. Disabled fields are not submitted from forms.

You could submit it as hidden fields - that’s one of the more common options.

Or, you could gather the data using some JavaScript and submit it either as form data or even as JSON.

It doesn’t - these elements of your project (HTML, views, forms and models) are all functionally independent. While they all work together and cooperate there are no mutual dependencies between them.

Adding a hidden field resolved the problem. Thanks.