Re: Inconsistency when importing views and models

2015-06-21 Thread James Schneider
>> If we were inspecting this code, we wouldn't know whether or not >> get_cat() comes from CatApp A or B, which makes troubleshooting more >> difficult, especially if both apps (or modules) define a get_cat() >> function. It would be much better to say: >> >> from CatAppA import get_cat >> from Ca

Re: Inconsistency when importing views and models

2015-06-21 Thread Carl Meyer
On 06/19/2015 11:41 PM, James Schneider wrote: > This is strictly a Python question, nothing Django-specific, but I've > found this site to be helpful in explaining the different ways to import > things: > > http://effbot.org/zone/import-confusion.htm This is good as far as it goes, but it is a

Re: Inconsistency when importing views and models

2015-06-21 Thread Carl Meyer
Hi, On 06/19/2015 08:32 PM, Peith Vergil wrote: > It depends on how your project files are structured. If you have a file > structure that looks like this: > > app/ > __init__.py > models.py > views.py > urls.py > > Then, you can simply use relative imports. > > In views.py: > f

Re: Inconsistency when importing views and models

2015-06-20 Thread jorrit787
Thank you for the very detailed explanations everyone! On Saturday, June 20, 2015 at 3:11:34 AM UTC+2, jorr...@gmail.com wrote: > > This is mostly a cosmetic question, and I could be completely wrong > because I'm fairly new to Django, or it could be that there is a perfectly > logical explanat

Re: Inconsistency when importing views and models

2015-06-19 Thread James Schneider
This is strictly a Python question, nothing Django-specific, but I've found this site to be helpful in explaining the different ways to import things: http://effbot.org/zone/import-confusion.htm In general, using 'from blah import *' is frowned upon except in very specific cases. While it is easi

Re: Inconsistency when importing views and models

2015-06-19 Thread Peith Vergil
It depends on how your project files are structured. If you have a file structure that looks like this: app/ __init__.py models.py views.py urls.py Then, you can simply use relative imports. In views.py: from models import * In urls.py: from views import * If, for example, your

Re: Inconsistency when importing views and models

2015-06-19 Thread Mike Dewhirst
On 20/06/2015 11:01 AM, jorrit...@gmail.com wrote: This is mostly a cosmetic question, and I could be completely wrong because I'm fairly new to Django, or it could be that there is a perfectly logical explanation for this, but here goes: It seems the code required to import views in urls.py and

Inconsistency when importing views and models

2015-06-19 Thread jorrit787
This is mostly a cosmetic question, and I could be completely wrong because I'm fairly new to Django, or it could be that there is a perfectly logical explanation for this, but here goes: It seems the code required to import views in urls.py and models in views.py is inconsistent (and in the ca