Monday, October 6, 2014

Re: Cannot import models from utility script

Den 06/10/2014 kl. 04.54 skrev Sithembewena Lloyd Dube <zebra05@gmail.com>:

> Hi all,
>
> I am using Django 1.7 and I have a package called 'utilities' next to my app package like so:
>
> --> my project
> --> my_app
> -- __init__.py
> -- models.py
> --> utilities
> -- __init__.py
> -- do_something.py
>
> Inside do_something.py in utilities, I am getting an ImportError when trying to do 'from my_app.models import Blah'.
>
> ImportError: No module named my_app.models

from my_project.my_app.models import Blah

or better, using relative imports:

from ..my_app.models import Blah


Erik

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/67A2FC50-A482-49D5-AABE-E05DFAC8D13E%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment