sorl / django-mockups

Can create auto-generated test data.
Other
74 stars 12 forks source link

Error while processing m2m #4

Open digitalfox opened 13 years ago

digitalfox commented 13 years ago

Hello,

I am using mocks from master branch ( f81e01892d97) and got the following strack trace :

/usr/lib64/python2.6/site-packages/mockups/helpers.py:21: UserWarning: Model Lead not in registry warnings.warn('Model %s not in registry' % model.name) Traceback (most recent call last): File "./manage.py", line 11, in execute_manager(settings) File "/usr/lib64/python2.6/site-packages/django/core/management/init.py", line 438, in execute_manager utility.execute() File "/usr/lib64/python2.6/site-packages/django/core/management/init.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib64/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(_args, _options.dict) File "/usr/lib64/python2.6/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(_args, _options) File "/usr/lib64/python2.6/site-packages/django/db/transaction.py", line 299, in _commit_on_success res = func(_args, *_kw) File "/usr/lib64/python2.6/site-packages/mockups/management/commands/mockups.py", line 218, in handle create(model, count, **kwargs) File "/usr/lib64/python2.6/site-packages/mockups/helpers.py", line 107, in create return mockup.create(count) File "/usr/lib64/python2.6/site-packages/mockups/base.py", line 341, in create instance = self.create_one(commit=commit) File "/usr/lib64/python2.6/site-packages/mockups/base.py", line 321, in create_one self.process_m2m(instance, field) File "/usr/lib64/python2.6/site-packages/mockups/base.py", line 233, in process_m2m auto_created_through_model = through._meta.auto_created AttributeError: 'NoneType' object has no attribute '_meta'

My model can be found here : (is is the Lead class) https://github.com/digitalfox/pydici/blob/master/leads/admin.py

Thanks for your help/

sorl commented 13 years ago

The Q support is not complete because its problematic, use {'active': True} in your limit_to in the mean time

digitalfox commented 13 years ago

Thanks for the { } tips. I remove Q() from all my models, but I still got this error.

artscoop commented 12 years ago

There is a problem in the process_m2m method: line 233, the code is: auto_created_through_model = through._meta.auto_created but correct code would be: auto_created_through_model = getattr(getattr(through, '_meta', None), 'auto_created', False)