request.POST = request.POST.copy()
;qd = QueryDict('', 'mutable')
qd[key] = value
request.POST = qd
request.POST['new_key'] = 'some value'
__init__
, куда параметром отдавайте нужное.class WorkForm(forms.Form)
road = forms.ModelChoicField(label='', queryset=Road.objects.none())
def __init__(self, *args, **kwargs):
user_id = kwargs.pop('user_id', None)
super(WorkForm, self).__init__(*args, **kwargs)
self.fields['road'].queryset = Roads.objects.filter(contractor=user_id)
date¶
Formats a date according to the given format.
Uses a similar format as PHP’s date() function (php.net/date) with some differences.
>>> d
datetime.date(2015, 1, 1)
>>> d.strftime('?y=%Y&m=%m&d=%d')
'?y=2015&m=01&d=01'
>>>
static RunPython.noop()¶
New in Django 1.8.
Pass the RunPython.noop method to code or reverse_code when you want the operation not to do anything in the given direction. This is especially useful in making the operation reversible.