Add initial data automatically idea

Hello,
I am new here in that amazing forum also I want to contribute. I have worked in different projects I realized something is when you enter data in your model to test your application. you have to add this data in your admin page or from your website page manually or maybe we can use JSON to do that. so what if we created something like Django Debug toolbar style that I can to select which fields that I want to fill out and how many queryset it will add in database and etc. all that automatically just you have to select which fields that you want to fill out and how many queryset it will add in database and click button. this my idea IDK if this idea already found.

Hi!

I’m not totally clear quite what you’re outlining - it sounds like some kind of factory interface for making test data? I don’t think that’s something we’d ship in Django, but it would probably work well as a separate standalone app - there’s a lot of tricky things to do though, data generation like this is hard. I’ve ended up writing this kind of stuff custom for each model in the past.

1 Like

thanks a lot of your response Sir. I will try to build something like that and I will tell you if that project success

@khaldon You should check out Factory Boy and Model Bakery. Both can help with the generation of dummy data.

I’ve used factory boy extensively (old post) and have used post migrate hooks to pre-fill the database from them (technique #3 in this post).

A UI for running factories from the browser or debug toolbar would be neat.

3 Likes

I’ll second @adamchainz here regarding Factory Boy. I’ve used it in the past to generate fake data for various tests. (It’s not exactly fast however. Generating a million rows will take a while…)