Можно объявить атрибут на Вашем ModelForm
класс, названный formfield_callback
. Это должно быть функцией, которая берет экземпляр модели Field
Django в качестве аргумента и возвращает форму Field
экземпляр для представления его в форме.
Тогда все, что необходимо сделать, надеются видеть, передало ли образцовое поле в, экземпляр DateField
и, если так, возвратите пользовательское поле/виджет. В противном случае образцовое поле будет иметь метод названным formfield
, что можно звонить для возврата его поля формы по умолчанию.
Так, что-то как:
def make_custom_datefield(f):
if isinstance(f, models.DateField):
# return form field with your custom widget here...
else:
return f.formfield()
class SomeForm(forms.ModelForm)
formfield_callback = make_custom_datefield
class Meta:
# normal modelform stuff here...
I have exactly the same problem and I have the following thoughts:
I do not know if SOAP is/should be state-full or stateless, can we open a session and if the user has supplied some form of credential keep her logged in for some period of time?
The other way I am thinking of solving this is through API-keys, say for example giving a key: ABCDKEY and having the url as:
http://####/services/soap-server/ABCDKEY
This introduces security risks (the magic link attack), but I've seen it implemented in RSS personalized feeds etc. Any comments?