Quantcast

Django 1.7: ImportError: No module named <appname>.models

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Django 1.7: ImportError: No module named <appname>.models

Malik Rumi

#admin.py:

    from apps.<appname>.models import Articles, Sections

ImportError: No module named <appname>.models

 

I have seen this error before, and it went away when I changed INSTALLED APPS from <appname> to apps.<appname> because I have all my apps in a folder called apps. Now I have changed even that to <appname>Config because of the 1.7 change to how this works. Apps.py is two levels down from here, so I don’t think there is a collision issue.

I tried changing the import statement to match the <appname>Config in INSTALLED APPS, but that just gave me the same error with the *Config name instead.

This is my model, it is clearly there, so I don’t know why or where this error is coming from or where to look to fix it. <appname> is all lower case, both in the Django directory and in admin.py. Just for the hell of it I capitalized <Appname> in admin.py, but I still get the same error. 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/aa401aa3-b9d9-4f01-9ac9-745f0360d311%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.7: ImportError: No module named <appname>.models

Malik Rumi
UPDATE

What is “.models”, why and when do we import from it, and how is it different from importing from “models”?

I’ve never seen this .models before. I saw it the first time this morning in the documentation https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.register when trying to solve this problem. But it just a casual mention, not an explanation. As I understood it, this was only for those choosing to use the new register decorator, so I didn’t worry about it. Now I’ve seen it again, in a video by a guy using 1.6 who, at least so far, has made no reference to a decorator of any kind.

Is this the source of my problems? Where is the documentation on “.models”? Yes, I have looked and found zip.

Thanks.


On Monday, August 11, 2014 8:43:29 AM UTC-5, Malik Rumi wrote:

#admin.py:

    from apps.<appname>.models import Articles, Sections

ImportError: No module named <appname>.models

 

I have seen this error before, and it went away when I changed INSTALLED APPS from <appname> to apps.<appname> because I have all my apps in a folder called apps. Now I have changed even that to <appname>Config because of the 1.7 change to how this works. Apps.py is two levels down from here, so I don’t think there is a collision issue.

I tried changing the import statement to match the <appname>Config in INSTALLED APPS, but that just gave me the same error with the *Config name instead.

This is my model, it is clearly there, so I don’t know why or where this error is coming from or where to look to fix it. <appname> is all lower case, both in the Django directory and in admin.py. Just for the hell of it I capitalized <Appname> in admin.py, but I still get the same error. 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/4a50755e-cd00-436d-b075-158c5227a4be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.7: ImportError: No module named <appname>.models

Tyrel Souza
.models is from PEP 328 http://legacy.python.org/dev/peps/pep-0328/
It's checking for models.py in the current module and it's knowns as a "relative import"


On Monday, August 11, 2014 1:35:50 PM UTC-4, Malik Rumi wrote:
UPDATE

What is “.models”, why and when do we import from it, and how is it different from importing from “models”?

I’ve never seen this .models before. I saw it the first time this morning in the documentation <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.register" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdocs.djangoproject.com%2Fen%2F1.7%2Fref%2Fcontrib%2Fadmin%2F%23django.contrib.admin.register\46sa\75D\46sntz\0751\46usg\75AFQjCNEQ5Ud99mtBQ8ptpBJZ_QQ9qXEnlA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdocs.djangoproject.com%2Fen%2F1.7%2Fref%2Fcontrib%2Fadmin%2F%23django.contrib.admin.register\46sa\75D\46sntz\0751\46usg\75AFQjCNEQ5Ud99mtBQ8ptpBJZ_QQ9qXEnlA';return true;">https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.register when trying to solve this problem. But it just a casual mention, not an explanation. As I understood it, this was only for those choosing to use the new register decorator, so I didn’t worry about it. Now I’ve seen it again, in a video by a guy using 1.6 who, at least so far, has made no reference to a decorator of any kind.

Is this the source of my problems? Where is the documentation on “.models”? Yes, I have looked and found zip.

Thanks.


On Monday, August 11, 2014 8:43:29 AM UTC-5, Malik Rumi wrote:

#admin.py:

    from apps.<appname>.models import Articles, Sections

ImportError: No module named <appname>.models

 

I have seen this error before, and it went away when I changed INSTALLED APPS from <appname> to apps.<appname> because I have all my apps in a folder called apps. Now I have changed even that to <appname>Config because of the 1.7 change to how this works. Apps.py is two levels down from here, so I don’t think there is a collision issue.

I tried changing the import statement to match the <appname>Config in INSTALLED APPS, but that just gave me the same error with the *Config name instead.

This is my model, it is clearly there, so I don’t know why or where this error is coming from or where to look to fix it. <appname> is all lower case, both in the Django directory and in admin.py. Just for the hell of it I capitalized <Appname> in admin.py, but I still get the same error. 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/ee462fb5-26fd-42cd-8a0d-7d0555f38d8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.7: ImportError: No module named <appname>.models

Malik Rumi
Ok, changing to .models seems to have fixed that error. On to the rest.... Thx!

On Monday, August 11, 2014 12:40:48 PM UTC-5, Tyrel Souza wrote:
.models is from PEP 328 <a href="http://legacy.python.org/dev/peps/pep-0328/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flegacy.python.org%2Fdev%2Fpeps%2Fpep-0328%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFqludMBZbHPcT32XP9s9xa2ddn3g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flegacy.python.org%2Fdev%2Fpeps%2Fpep-0328%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNFqludMBZbHPcT32XP9s9xa2ddn3g';return true;">http://legacy.python.org/dev/peps/pep-0328/
It's checking for models.py in the current module and it's knowns as a "relative import"


On Monday, August 11, 2014 1:35:50 PM UTC-4, Malik Rumi wrote:
UPDATE

What is “.models”, why and when do we import from it, and how is it different from importing from “models”?

I’ve never seen this .models before. I saw it the first time this morning in the documentation <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.register" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdocs.djangoproject.com%2Fen%2F1.7%2Fref%2Fcontrib%2Fadmin%2F%23django.contrib.admin.register\46sa\75D\46sntz\0751\46usg\75AFQjCNEQ5Ud99mtBQ8ptpBJZ_QQ9qXEnlA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fdocs.djangoproject.com%2Fen%2F1.7%2Fref%2Fcontrib%2Fadmin%2F%23django.contrib.admin.register\46sa\75D\46sntz\0751\46usg\75AFQjCNEQ5Ud99mtBQ8ptpBJZ_QQ9qXEnlA';return true;">https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.register when trying to solve this problem. But it just a casual mention, not an explanation. As I understood it, this was only for those choosing to use the new register decorator, so I didn’t worry about it. Now I’ve seen it again, in a video by a guy using 1.6 who, at least so far, has made no reference to a decorator of any kind.

Is this the source of my problems? Where is the documentation on “.models”? Yes, I have looked and found zip.

Thanks.


On Monday, August 11, 2014 8:43:29 AM UTC-5, Malik Rumi wrote:

#admin.py:

    from apps.<appname>.models import Articles, Sections

ImportError: No module named <appname>.models

 

I have seen this error before, and it went away when I changed INSTALLED APPS from <appname> to apps.<appname> because I have all my apps in a folder called apps. Now I have changed even that to <appname>Config because of the 1.7 change to how this works. Apps.py is two levels down from here, so I don’t think there is a collision issue.

I tried changing the import statement to match the <appname>Config in INSTALLED APPS, but that just gave me the same error with the *Config name instead.

This is my model, it is clearly there, so I don’t know why or where this error is coming from or where to look to fix it. <appname> is all lower case, both in the Django directory and in admin.py. Just for the hell of it I capitalized <Appname> in admin.py, but I still get the same error. 

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/506d841b-c4a5-4d85-acf1-007a42ea1b8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.7: ImportError: No module named <appname>.models

ngangsia akumbo
In reply to this post by Malik Rumi
i have had this same erroe too but it happed that i include instead the module class name in the settings.py file

make sure u are having the name of the app in the settings.py file

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/4cae3225-4abd-4ffc-b518-8ad9d2c2c57b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Django 1.7: ImportError: No module named <appname>.models

Leonard Cohen
I WENT ALMOST CRAZY thanx a lot !!! ;)

Τη Τρίτη, 12 Αυγούστου 2014 - 12:19:34 μ.μ. UTC+3, ο χρήστης ngangsia akumbo έγραψε:
i have had this same erroe too but it happed that i include instead the module class name in the settings.py file

make sure u are having the name of the app in the settings.py file

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bd70d3e0-df69-448d-85ba-ff40b7d6af21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...