from django import forms
from django.db.models import get_model
from django.forms.models import inlineformset_factory

WishList = get_model('wishlists', 'WishList')
Line = get_model('wishlists', 'Line')


class WishListForm(forms.ModelForm):

    def __init__(self, user, *args, **kwargs):
        super(WishListForm, self).__init__(*args, **kwargs)
        self.instance.owner = user

    class Meta:
        model = WishList
        fields = ('name', )


LineFormset = inlineformset_factory(WishList, Line, fields=('quantity', ),
                                    extra=0, can_delete=False)

from django import forms
from django.db.models import get_model
from django.forms.models import inlineformset_factory, fields_for_model

WishList = get_model('wishlists', 'WishList')
Line = get_model('wishlists', 'Line')


class WishListForm(forms.ModelForm):

    def __init__(self, user, *args, **kwargs):
        super(WishListForm, self).__init__(*args, **kwargs)
        self.instance.owner = user

    class Meta:
        model = WishList
        fields = ('name', )


class WishListLineForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super(WishListLineForm, self).__init__(*args, **kwargs)
        self.fields['quantity'].widget.attrs['size'] = 2


LineFormset = inlineformset_factory(
    WishList, Line, fields=('quantity', ), form=WishListLineForm,
    extra=0, can_delete=False)

Set size on wishlist line quantity form field
Set size on wishlist line quantity form field

This doesn't actually work since there is an overriding CSS style.  When
issue #851 is resolved, this should start working.

  from django import forms
  from django.db.models import get_model
- from django.forms.models import inlineformset_factory
+ from django.forms.models import inlineformset_factory, fields_for_model
  
  WishList = get_model('wishlists', 'WishList')
  Line = get_model('wishlists', 'Line')
  
  
  class WishListForm(forms.ModelForm):
  
      def __init__(self, user, *args, **kwargs):
          super(WishListForm, self).__init__(*args, **kwargs)
          self.instance.owner = user
  
      class Meta:
          model = WishList
          fields = ('name', )
  
  
+ class WishListLineForm(forms.ModelForm):
- LineFormset = inlineformset_factory(WishList, Line, fields=('quantity', ),
-                                     extra=0, can_delete=False)
  
+     def __init__(self, *args, **kwargs):
+         super(WishListLineForm, self).__init__(*args, **kwargs)
+         self.fields['quantity'].widget.attrs['size'] = 2
+ 
+ 
+ LineFormset = inlineformset_factory(
+     WishList, Line, fields=('quantity', ), form=WishListLineForm,
+     extra=0, can_delete=False)
+ 
Set size on wishlist line quantity form field
## Code Before:
from django import forms
from django.db.models import get_model
from django.forms.models import inlineformset_factory

WishList = get_model('wishlists', 'WishList')
Line = get_model('wishlists', 'Line')


class WishListForm(forms.ModelForm):

    def __init__(self, user, *args, **kwargs):
        super(WishListForm, self).__init__(*args, **kwargs)
        self.instance.owner = user

    class Meta:
        model = WishList
        fields = ('name', )


LineFormset = inlineformset_factory(WishList, Line, fields=('quantity', ),
                                    extra=0, can_delete=False)

## Instruction:
Set size on wishlist line quantity form field
## Code After:
from django import forms
from django.db.models import get_model
from django.forms.models import inlineformset_factory, fields_for_model

WishList = get_model('wishlists', 'WishList')
Line = get_model('wishlists', 'Line')


class WishListForm(forms.ModelForm):

    def __init__(self, user, *args, **kwargs):
        super(WishListForm, self).__init__(*args, **kwargs)
        self.instance.owner = user

    class Meta:
        model = WishList
        fields = ('name', )


class WishListLineForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super(WishListLineForm, self).__init__(*args, **kwargs)
        self.fields['quantity'].widget.attrs['size'] = 2


LineFormset = inlineformset_factory(
    WishList, Line, fields=('quantity', ), form=WishListLineForm,
    extra=0, can_delete=False)
