*Even if you write

from models import Publisher, Book, Author

its gonna work, inside the books application;
*
On Wed, Aug 24, 2011 at 7:09 AM, Jim <jianbao....@gmail.com> wrote:

> Greetings, everyone.
>
> I am new to Django, and much of my knowledge comes from the Django book
> version 2 <http://www.djangobook.com/en/2.0/>. In the book, a site,
> mysite, is created for demo purposes. And an app, books, is also created for
> demo purposes. In the file, mysite/books/admin.py, there is a line like
> this:
>
>
> from mysite.books.models import Publisher, Author, Book
>
> It seems to me that this line makes the app dependent on the name of the
> site, which is mysite. There is a possibility that an app you have developed
> for a site might turn out to have generic use. So, I think it is a good idea
> to always keep an app independent on the site as much as possible.
>
> Here is the question. Is it possible that to store the site name into a
> variable, such as site_name, then construct a statement like the following?
>
> statement = 'from ' + site_name + '.books.models import Publisher' 
> exec(statement)
> # I am not sure if exec is a legitimate function. Here is just an example
>
>
>
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Jn_07ca2t6MJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to