class Meta: model = Shop exclude = ('balance', 'rank','level') widgets = { 'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Shop name'}), 'shop_phone': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '+212612345678'}), 'shop_email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': '*****@*****.**'}), 'vat': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '20'}), 'country': forms.Select(attrs={'class': 'form-control', 'placeholder': 'Country'}), # 'city': forms.Select(attrs={'class': 'form-control', 'placeholder': 'City'}), 'city': ChainedSelect( app_name='simplecities', model_name='city', chain_field='country', model_field='country', show_all=False, auto_choose=False, attrs={'class': 'form-control'}, # select2_options={'width': '100%'} ), 'address': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Shop address'}), 'description': forms.Textarea(attrs={'class': 'form-control'}), 'location': LocationWidget(attrs={'class': 'form-control'}), 'logo': FrontImageWidget(attrs={'class': 'form-control'}), 'website': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Website'}), 'facebook': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Facebook'}), 'twitter': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Twitter'}), 'google_plus': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Google Plus'}), 'paypal_email': forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'Your paypal account email'}), }
def __init__(self, app_name, model_name, chain_field, model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, manager=None, initial=None, view_name=None, *args, **kwargs): defaults = { 'widget': ChainedSelect(app_name, model_name, chain_field, model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, manager, view_name), } defaults.update(kwargs) if not 'queryset' in kwargs: queryset = get_model(app_name, model_name).objects.all() super(ChainedModelChoiceField, self).__init__(queryset=queryset, initial=initial, *args, **defaults) else: super(ChainedModelChoiceField, self).__init__(initial=initial, *args, **defaults)
def __init__(self, app_name, model_name, chain_field, model_field, show_all, auto_choose, manager=None, initial=None, *args, **kwargs): defaults = { 'widget': ChainedSelect(app_name, model_name, chain_field, model_field, show_all, auto_choose, manager), } defaults.update(kwargs) if 'queryset' not in kwargs: queryset = apps.get_model(app_name, model_name).objects.all() super().__init__(queryset=queryset, initial=initial, *args, **defaults) else: super().__init__(initial=initial, *args, **defaults)
def __init__(self, to_app_name, to_model_name, chained_field, chained_child_app, chained_child_model, chained_child_field, chained_model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, sort=True, manager=None, initial=None, view_name=None, *args, **kwargs): defaults = { "widget": ChainedSelect( to_app_name, to_model_name, chained_field, chained_child_app, chained_child_model, chained_child_field, chained_model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, sort, manager, view_name, ), } defaults.update(kwargs) if "queryset" not in kwargs: queryset = get_model(to_app_name, to_model_name).objects.all() super(ChainedModelChoiceField, self).__init__(queryset=queryset, initial=initial, *args, **defaults) else: super(ChainedModelChoiceField, self).__init__(initial=initial, *args, **defaults)
class Meta: widgets = { 'model': ChainedSelect( app_name='phone', model_name='model', chain_field='id_brand', model_field='brand', show_all=False, auto_choose=False, attrs={'class': 'form-control'}, # select2_options={"width": "100%"} ), }
class Meta: model = Component exclude = ( 'sold', 'deleted', 'shop', ) widgets = { 'image': forms.FileInput(attrs={'class': 'form-control'}), 'title': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Title' }), 'brand': forms.Select( # attrs={'class': 'form-control'} ), # 'brand': Select2Widget(select2_options={'width': '100%'}), 'model': ChainedSelect( app_name='phone', model_name='model', chain_field='brand', model_field='brand', show_all=False, auto_choose=False, # attrs={'class': 'form-control'}, # select2_options={'width': '100%'} ), 'type': forms.Select( # attrs={'class': 'form-control'} ), # 'type': Select2Widget(select2_options={'width': '100%'}), 'description': forms.Textarea(attrs={'class': 'form-control'}), 'price': forms.NumberInput(attrs={ 'class': 'form-control', 'min': '0' }), 'currency': forms.Select(attrs={ 'class': 'form-control', }), }
class Meta: model = ServerOrder fields = ('endpoint', 'service', 'imei', 'brand', 'model') widgets = { 'imei': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Imei'}), 'brand': forms.Select( attrs={'class': 'form-control searchselect'} ), 'model': ChainedSelect( app_name='phone', model_name='model', chain_field='brand', model_field='brand', show_all=False, auto_choose=False, attrs={'class': 'form-control searchselect'}, # select2_options={"width": "100%"} ), }
def __init__(self, to_app_name, to_model_name, chained_field, chained_model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, sort=True, manager=None, initial=None, view_name=None, display_field=None, *args, **kwargs): self.to_app_name=to_app_name self.to_model_name=to_model_name self.chained_field=chained_field self.chained_model_field=chained_model_field self.foreign_key_app_name=foreign_key_app_name self.foreign_key_model_name=foreign_key_model_name self.foreign_key_field_name=foreign_key_field_name self.display_field=display_field defaults = { 'widget': ChainedSelect(to_app_name, to_model_name, chained_field, chained_model_field, foreign_key_app_name, foreign_key_model_name, foreign_key_field_name, show_all, auto_choose, sort, display_field, manager, view_name), } defaults.update(kwargs) if 'queryset' not in kwargs: queryset = get_model(to_app_name, to_model_name).objects.all() super(ChainedModelChoiceField, self).__init__(queryset=queryset, initial=initial, *args, **defaults) else: super(ChainedModelChoiceField, self).__init__(initial=initial, *args, **defaults)
class Meta: model = Client exclude = ('shop', 'paid_for', 'deleted', 'delivered_at') widgets = { 'brand': forms.Select( # attrs={'class': 'form-control'} ), # 'brand': Select2Widget(select2_options={'width': '100%'}), 'status': forms.Select(attrs={'class': 'form-control'}), 'todo': forms.Select(attrs={'class': 'form-control'}), 'model': ChainedSelect( app_name='phone', model_name='model', chain_field='brand', model_field='brand', show_all=False, auto_choose=False, # attrs={'class': 'form-control'}, # select2_options={"width": "100%"} ), 'amount': forms.NumberInput(attrs={ 'class': 'form-control', 'min': '0', 'placeholder': 'Amount' }), 'status_description': forms.Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Status description' }), 'todo_description': forms.Textarea(attrs={ 'class': 'form-control', 'placeholder': 'Todo description' }), 'serial': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Serial' }), 'imei': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Imei' }), 'ref': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Ref', 'readonly': 'true' }), 'email': forms.EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Email' }), 'serial': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Serial' }), 'phone_number': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': '+212612345678' }), 'delivery_time': forms.DateTimeInput(attrs={'class': 'form-control'}), }
def __init__(self, app_name, model_name, chain_field, model_field, initial=None, *args, **kwargs): defaults = { 'widget': ChainedSelect(app_name, model_name, chain_field, model_field), } defaults.update(kwargs) super(ChainedModelChoiceField, self).__init__(initial=initial, *args, **defaults)