can you tell me the exact place of the example which should help me in the docs that you talk about. All I can find is the code to set the value of a normal char in the views.
# Create a form instance with POST data.
>>> f = AuthorForm(request.POST)
# Create, but don't save the new author instance.
>>> new_author = f.save(commit=False)
# Modify the author in some way.
>>> new_author.some_field = 'some_value'
# Save the new instance.
>>> new_author.save()
If thatâs the line that youâre questioning, itâs ok. There is nothing fundamentally different about the assignment of an id vs the assignment of a character field.
You donât have to get by primary key. (Itâs an example, not a requirement or limitation.)
You can use the get method with any valid query, as long as it retrieves one and only one row.