Im using faker and factory boy to populate my database with fake data. Currently, I'm working with location.
The setup that I'm running now populates the table but is mismatched.
class LocationFactory(DjangoModelFactory):
class Meta:
model = Location
city = factory.LazyAttribute(lambda o: FAKE.city())
street = factory.LazyAttribute(lambda o: FAKE.street_name())
state = factory.LazyAttribute(lambda o: FAKE.city_suffix())
country = factory.LazyAttribute(lambda o: FAKE.country())
placeId = factory.LazyAttribute(lambda o: FAKE.pystr())
latitude = factory.LazyAttribute(lambda o: FAKE.latitude())
longitude = factory.LazyAttribute(lambda o: FAKE.longitude())
so when i run this I get city/stret/state/lat/long in correct format but it's random. The city is in US but the country is somewhere in Europe and the coordinates are in artica.
What was naively trying to do is to use
FAKE.local_latlng(country_code= 'US')
like this
class LocationFactory(DjangoModelFactory):
class Meta:
model = Location
geo_data = FAKE.local_latlng(country_code= 'US')
city = geo_data[2]
street = factory.LazyAttribute(lambda o: FAKE.street_name())
state = geo_data[4]
country = geo_data[3]
placeId = factory.LazyAttribute(lambda o: FAKE.pystr())
longitude = geo_data[0]
latitude = geo_data[1]
but we all know that this does not work in django
How can I get
FAKE.local_latlng(country_code= 'US')
to work