您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

forms.py 555B

1234567891011121314151617
  1. from django.forms import ModelForm
  2. from django.db.models import get_model
  3. class ShippingAddressForm(ModelForm):
  4. def __init__(self, *args, **kwargs):
  5. super(ShippingAddressForm,self ).__init__(*args, **kwargs)
  6. self.set_country_queryset()
  7. def set_country_queryset(self):
  8. self.fields['country'].queryset = get_model('address', 'country')._default_manager.filter(is_shipping_country=True)
  9. class Meta:
  10. model = get_model('order', 'shippingaddress')
  11. exclude = ('user', 'search_text')