Closed davidthewatson closed 12 years ago
What is the db_now() function? btw, i truncated your stacktrace, there were hundreds of lines of dupe data.
I should add that I do not experience this problem locally and the test suite is passing. Have you tried running the example app that ships w/flask-peewee and do you observe the same thing?
Hmm, another consideration -- do you have another model which foreign keys to Pool
and specifies a related_name
? The reason I ask is that the __get__()
is a method on the ReverseForeignRelatedObject
...the only reason I can think that it would be called when doing the get_field_dict()
is if its name collided with an existing field name. Can you do some interactive debugging and find out what field is causing the recursion? That might help.
Yep, that's it. I had two models that specified related_name='id' which is obviously stupid. I just didn't see how that was going to manifest at runtime and that its effect was catastrophic. Thanks for your help.
Glad it fixed it -- yes, related_name is used for the back-side of a foreign key, so 0..n related models. Typically they are expressed as a plural, i.e. for message in user.messages:
Where Message has a Foreign key to user that looks like user = ForeignKeyField(User, related_name='messages')
I've got the following on fedora core 16 with postgresql:
I have a peewee model like this:
When I access the generated admin at http://localhost:5000/admin/pool/add/
and type a name in the name field with the other two fields defaulting, I get the following:
Traceback (most recent call last): File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask/app.py", line 1506, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask/app.py", line 1504, in wsgi_app response = self.full_dispatch_request() File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request rv = self.dispatch_request() File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask_debugtoolbar/init.py", line 101, in dispatch_request return view_func(_req.view_args) File "/usr/lib64/python2.7/cProfile.py", line 149, in runcall return func(_args, _kw) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask_peewee/admin.py", line 521, in inner return func(_args, kwargs) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask_peewee/admin.py", line 259, in add instance = self.save_model(self.model(), form, True) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/flask_peewee/admin.py", line 200, in save_model instance.save() File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2586, in save field_dict = self.get_field_dict() File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2508, in get_field_dict field_dict[field.name] = getattr(self, field.name) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2249, in get** query = {self.field_name: instance.get_pk()} File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2579, in get_pk return getattr(self, self._meta.pk_name, None) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2249, in get query = {self.field_name: instance.get_pk()} File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2579, in get_pk return getattr(self, self._meta.pk_name, None) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2249, in get query = {self.field_name: instance.get_pk()} File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2579, in get_pk return getattr(self, self._meta.pk_name, None) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2249, in get query = {self.field_name: instance.get_pk()} File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2579, in get_pk return getattr(self, self._meta.pk_name, None) File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2249, in get query = {self.field_name: instance.get_pk()} File "/home/watson/git/latte/virtenv/lib/python2.7/site-packages/peewee.py", line 2579, in get_pk return getattr(self, self._meta.pk_name, None)