{"issue":{"created_at":"2011-12-10T14:26:27Z","state":"open","updated_at":"2011-12-15T19:16:56Z","user":{"gravatar_id":"1a1f4b0b137eff840ee51a4d67e7726d","id":63589,"url":"https://api.github.com/users/simonluijk","login":"simonluijk","avatar_url":"https://secure.gravatar.com/avatar/1a1f4b0b137eff840ee51a4d67e7726d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":2,"body":"The underlying problem is when you import\r\n\r\nshop.models.defaults.bases.BaseProduct\r\n\r\nor the other base models in your project. It will also\r\nimport shop/models/__init__.py if you then have the\r\nSHOP_x_MODEL set to a Model you later define in this\r\nsame file, you will get a circular import. Or if you use\r\nthe other solutions so far, django-SHOP will try and import\r\nthe custom model before it has been instantiated. The only\r\nway to fix this is to move anything the project needs to\r\nbuild a custom module outside shop.models. At the moment\r\nthat is base models and managers. This needs to be done\r\nin combination with the previous solution, which I have\r\nincluded here.\r\n\r\nThere are a few fixes that can be applied to make this\r\nbackwards compatible. Are you maintaining backwards\r\ncompatibility before 1.0?\r\n\r\nTests are on their way. But right now it is an unusually\r\nsunny day for this time of year :)\r\n\r\nSigned-off-by: Simon Luijk <simon@luijk.co.uk>","assignee":null,"id":2511158,"number":125,"pull_request":{"patch_url":"https://github.com/divio/django-shop/pull/125.patch","html_url":"https://github.com/divio/django-shop/pull/125","diff_url":"https://github.com/divio/django-shop/pull/125.diff"},"labels":[],"title":"Prevent circular imports when defining custom shop models","html_url":"https://github.com/divio/django-shop/issues/125","closed_at":null,"url":"https://api.github.com/repos/divio/django-shop/issues/125","milestone":null},"action":"created","comment":{"created_at":"2011-12-15T19:16:56Z","updated_at":"2011-12-15T19:16:56Z","user":{"gravatar_id":"1a1f4b0b137eff840ee51a4d67e7726d","id":63589,"url":"https://api.github.com/users/simonluijk","login":"simonluijk","avatar_url":"https://secure.gravatar.com/avatar/1a1f4b0b137eff840ee51a4d67e7726d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I have two more test cases in mind, but am having trouble implementing them as the error occurs as Django loads the installed app's models. I have not been able to force Django to reload the models without running an external script from a test case. Anyone have any ideas? I have tried clearing AppCache but still no luck!\r\n\r\nI have not put any thought into a test case for the code that was added and discussed in \r\nhttps://github.com/divio/django-shop/pull/108\r\n\r\n","id":3167314,"url":"https://api.github.com/repos/divio/django-shop/issues/comments/3167314"}}