Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

forms.py 659B

123456789101112131415161718192021
  1. from django.forms import ModelForm
  2. from oscar.core.loading import import_module
  3. address_models = import_module('address.models', ['Country'])
  4. order_models = import_module('order.models', ['ShippingAddress'])
  5. class ShippingAddressForm(ModelForm):
  6. def __init__(self, *args, **kwargs):
  7. super(ShippingAddressForm,self ).__init__(*args, **kwargs)
  8. self.set_country_queryset()
  9. def set_country_queryset(self):
  10. self.fields['country'].queryset = address_models.Country._default_manager.filter(is_shipping_country=True)
  11. class Meta:
  12. model = order_models.ShippingAddress
  13. exclude = ('user',)