Do not create models with args parameters. If you make a model like this:
User('name','email')
It becomes very unreadable very quickly, since most models require more than for initialization. You could easily end up with:
User('Bert', 'Reynolds', 'me@bertreynolds.com','0123456789','5432106789',....)
Another problem is that you donβt know if Bert is the first or the last. The last two numbers may simply be a phone number and a system identifier. But without its explicit you will be easier to mix them or mix order, if you use identifiers. Moreover, doing this on the basis of an order will be another limitation for other developers who use this method and will not remember the arbitrary order of the parameters.
Instead, you should prefer something like this:
User( first_name='Bert', last_name='Reynolds', email='me@bertreynolds.com', phone='0123456789', system_id='5432106789', )
If it's for tests or something like that, you can use factory to quickly create models. Link to factory link may be useful: http://factoryboy.readthedocs.org/en/latest/
unflores Jan 20 '15 at 16:13 2015-01-20 16:13
source share