kopia lustrzana https://github.com/jedie/PyInventory
FIX #33 by set user before save the image
rodzic
b3620806c7
commit
7ace3018c6
|
@ -26,6 +26,15 @@ class BaseUserOnlyModelForm(forms.ModelForm):
|
||||||
|
|
||||||
formfield.queryset = queryset.filter(user=user)
|
formfield.queryset = queryset.filter(user=user)
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
instance = super().save(commit=False)
|
||||||
|
if instance.user_id is None:
|
||||||
|
user = get_request_dict()['user'] # get current user via threading.local()
|
||||||
|
instance.user_id = user.pk
|
||||||
|
|
||||||
|
instance.save()
|
||||||
|
return instance
|
||||||
|
|
||||||
|
|
||||||
class ItemModelModelForm(BaseUserOnlyModelForm):
|
class ItemModelModelForm(BaseUserOnlyModelForm):
|
||||||
pass
|
pass
|
||||||
|
|
Ładowanie…
Reference in New Issue