Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Address(models.Model):
- first_line = models.CharField(max_length=50, blank=True)
- second_line = models.CharField(max_length=50, blank=True)
- city = models.CharField(max_length=30, blank=True)
- state = models.CharField(max_length=2, blank=True)
- zipcode = models.CharField(max_length=5, blank=True)
- zipcode_ext = models.CharField(max_length=4, blank=True)
- class AddressFactory(factory.django.DjangoModelFactory):
- class Meta:
- model = Address
- first_line = "555 Main St."
- second_line = "Unit 2"
- city = "Chicago"
- state = "IL"
- zipcode = "60606"
- zipcode_ext = "1234"
- >>> from models import Address
- >>> from django.forms.models import modelform_factory
- >>> AddressForm = modelform_factory(Address)
- >>> from factories import AddressFactory
- >>> a = AddressFactory.create()
- >>> af = AddressForm(instance = a)
- >>> af.is_valid()
- False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement