question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set lazy by default

See original GitHub issue

This is a feature request.

For people using Faker indeed makes sense to set all attributes “lazy” while setting fixed values only on special cases.

I did have a bad time trying to make it work and ended up using a bunch of factory.LazyFunction(lambda:

Set all calls from random “lazy” would be ok too, but indeed having it as an option makes more sense.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
stephenrosscommented, Mar 27, 2018

You can also use something like the following for some of your objects (I have made some assumptions and provided some of the issues with those assumptions in comments):

type_id = factory.Faker('random_element', elements=TypeCompany.objects.values_list('id', flat=True))
city = factory.Iterator(City.objects.all())
region_id = factory.SelfAttribute('city.region_id')
bank_id = factory.Faker('random_element', elements=Bank.objects.values_list('id', flat=True))
account = factory.Faker('random_int', min=10000000, max=99999999)
status = factory.Faker('random_element', elements=STATUS_CHOICES.keys()) # Assuming [0] was to grab the key of the selected STATUS_CHOICES element
2reactions
hacktivistacommented, Sep 1, 2017

I thought it was deprecated… I think the current state of the integration with faker is confusing 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I set the default behavior of lazy init in Spring Boot?
I want to set the that for default all beans are lazy loaded. I know that I can add the @Lazy to all...
Read more >
Lazy Initialization in Spring Boot 2.2 - Baeldung
By default in Spring, all the defined beans, and their dependencies, are created when the application context is created.
Read more >
Lazy Initialization - .NET Framework - Microsoft Learn
Initialize by using default Lazy<T> constructor. The // Orders array itself is not created yet. Lazy<Orders> _orders = new Lazy<Orders>();
Read more >
Lazy Initialization in Spring Boot 2.2
By default, when an application context is being refreshed, every bean in the context is created and its dependencies are injected.
Read more >
Understanding Lazy Initialization in Spring Boot - SpringHow
By default, Spring Framework creates and injects beans and it's dependencies at the time of context creation or refresh. But with lazy mode, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found