|
|
@@ -1,7 +1,7 @@
|
|
1
|
1
|
# -*- coding: utf-8 -*-
|
|
2
|
2
|
from django import forms
|
|
3
|
3
|
from django.db.models import get_model
|
|
4
|
|
-from django.forms.models import inlineformset_factory
|
|
|
4
|
+from django.forms.models import inlineformset_factory, fields_for_model
|
|
5
|
5
|
|
|
6
|
6
|
WishList = get_model('wishlists', 'WishList')
|
|
7
|
7
|
Line = get_model('wishlists', 'Line')
|
|
|
@@ -18,5 +18,13 @@ class WishListForm(forms.ModelForm):
|
|
18
|
18
|
fields = ('name', )
|
|
19
|
19
|
|
|
20
|
20
|
|
|
21
|
|
-LineFormset = inlineformset_factory(WishList, Line, fields=('quantity', ),
|
|
22
|
|
- extra=0, can_delete=False)
|
|
|
21
|
+class WishListLineForm(forms.ModelForm):
|
|
|
22
|
+
|
|
|
23
|
+ def __init__(self, *args, **kwargs):
|
|
|
24
|
+ super(WishListLineForm, self).__init__(*args, **kwargs)
|
|
|
25
|
+ self.fields['quantity'].widget.attrs['size'] = 2
|
|
|
26
|
+
|
|
|
27
|
+
|
|
|
28
|
+LineFormset = inlineformset_factory(
|
|
|
29
|
+ WishList, Line, fields=('quantity', ), form=WishListLineForm,
|
|
|
30
|
+ extra=0, can_delete=False)
|