django no module name












-1















i am trying to set up a project and every time i runserver it tells me there is no module named 'views' that i am trying to import to the urls.py of the same folder!



  from django.conf.urls import url 
import views
urlpatterns = [
'products.views', url(r'^$', ProductListView.as_view(), name='product_list')


i tried every possible solution and nothing worked :



├───carts
│ ├───migrations
│ └───__pycache__
├───ecommerce
│ └───__pycache__
├───newsletter
│ ├───migrations
│ └───__pycache__
├───orders
│ ├───migrations
│ └───__pycache__
├───products
│ ├───migrations
│ └───__pycache__
├───statics
│ └───our_static
│ ├───css
│ ├───img
│ ├───js
│ └───psd
└───templates
├───carts
├───orders
├───products
└───registration


the views file that i want to import should be under products, i tried setting the PYTHONPATH but that didn't work either everything i do it either tells me the module doesn't exist or throws a weird syntax error in the views file print formset.is_valid() which i figured is totally unrelated does anyone have an explanation for this?
thank you.










share|improve this question

























  • tree command shows folder structure, not files.

    – ruddra
    Nov 13 '18 at 4:48











  • simply use from . import views or if you wanted to import views of some other app use from app import views

    – Jagjeet Singh
    Nov 13 '18 at 5:26











  • File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:52


















-1















i am trying to set up a project and every time i runserver it tells me there is no module named 'views' that i am trying to import to the urls.py of the same folder!



  from django.conf.urls import url 
import views
urlpatterns = [
'products.views', url(r'^$', ProductListView.as_view(), name='product_list')


i tried every possible solution and nothing worked :



├───carts
│ ├───migrations
│ └───__pycache__
├───ecommerce
│ └───__pycache__
├───newsletter
│ ├───migrations
│ └───__pycache__
├───orders
│ ├───migrations
│ └───__pycache__
├───products
│ ├───migrations
│ └───__pycache__
├───statics
│ └───our_static
│ ├───css
│ ├───img
│ ├───js
│ └───psd
└───templates
├───carts
├───orders
├───products
└───registration


the views file that i want to import should be under products, i tried setting the PYTHONPATH but that didn't work either everything i do it either tells me the module doesn't exist or throws a weird syntax error in the views file print formset.is_valid() which i figured is totally unrelated does anyone have an explanation for this?
thank you.










share|improve this question

























  • tree command shows folder structure, not files.

    – ruddra
    Nov 13 '18 at 4:48











  • simply use from . import views or if you wanted to import views of some other app use from app import views

    – Jagjeet Singh
    Nov 13 '18 at 5:26











  • File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:52
















-1












-1








-1








i am trying to set up a project and every time i runserver it tells me there is no module named 'views' that i am trying to import to the urls.py of the same folder!



  from django.conf.urls import url 
import views
urlpatterns = [
'products.views', url(r'^$', ProductListView.as_view(), name='product_list')


i tried every possible solution and nothing worked :



├───carts
│ ├───migrations
│ └───__pycache__
├───ecommerce
│ └───__pycache__
├───newsletter
│ ├───migrations
│ └───__pycache__
├───orders
│ ├───migrations
│ └───__pycache__
├───products
│ ├───migrations
│ └───__pycache__
├───statics
│ └───our_static
│ ├───css
│ ├───img
│ ├───js
│ └───psd
└───templates
├───carts
├───orders
├───products
└───registration


the views file that i want to import should be under products, i tried setting the PYTHONPATH but that didn't work either everything i do it either tells me the module doesn't exist or throws a weird syntax error in the views file print formset.is_valid() which i figured is totally unrelated does anyone have an explanation for this?
thank you.










share|improve this question
















i am trying to set up a project and every time i runserver it tells me there is no module named 'views' that i am trying to import to the urls.py of the same folder!



  from django.conf.urls import url 
import views
urlpatterns = [
'products.views', url(r'^$', ProductListView.as_view(), name='product_list')


i tried every possible solution and nothing worked :



├───carts
│ ├───migrations
│ └───__pycache__
├───ecommerce
│ └───__pycache__
├───newsletter
│ ├───migrations
│ └───__pycache__
├───orders
│ ├───migrations
│ └───__pycache__
├───products
│ ├───migrations
│ └───__pycache__
├───statics
│ └───our_static
│ ├───css
│ ├───img
│ ├───js
│ └───psd
└───templates
├───carts
├───orders
├───products
└───registration


the views file that i want to import should be under products, i tried setting the PYTHONPATH but that didn't work either everything i do it either tells me the module doesn't exist or throws a weird syntax error in the views file print formset.is_valid() which i figured is totally unrelated does anyone have an explanation for this?
thank you.







python django django-forms django-views






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 17:59







ahmed cheikh sidahmed

















asked Nov 13 '18 at 4:03









ahmed cheikh sidahmedahmed cheikh sidahmed

64




64













  • tree command shows folder structure, not files.

    – ruddra
    Nov 13 '18 at 4:48











  • simply use from . import views or if you wanted to import views of some other app use from app import views

    – Jagjeet Singh
    Nov 13 '18 at 5:26











  • File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:52





















  • tree command shows folder structure, not files.

    – ruddra
    Nov 13 '18 at 4:48











  • simply use from . import views or if you wanted to import views of some other app use from app import views

    – Jagjeet Singh
    Nov 13 '18 at 5:26











  • File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:52



















tree command shows folder structure, not files.

– ruddra
Nov 13 '18 at 4:48





tree command shows folder structure, not files.

– ruddra
Nov 13 '18 at 4:48













simply use from . import views or if you wanted to import views of some other app use from app import views

– Jagjeet Singh
Nov 13 '18 at 5:26





simply use from . import views or if you wanted to import views of some other app use from app import views

– Jagjeet Singh
Nov 13 '18 at 5:26













File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

– ahmed cheikh sidahmed
Nov 13 '18 at 17:52







File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax this is what it does when i import views from . weird behaviour isn't it?

– ahmed cheikh sidahmed
Nov 13 '18 at 17:52














2 Answers
2






active

oldest

votes


















0














Import views like this:



 from .views import * 


You are using class based views so this method will work.






share|improve this answer
























  • tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:54











  • Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

    – Faizan Fareed
    Nov 13 '18 at 18:08











  • actually that was it thank you very much!

    – ahmed cheikh sidahmed
    Nov 13 '18 at 18:24



















0














Change your urlpatterns to this:



urlpatterns = [
url(r'^$', ProductListView.as_view(template_name="product_list"),),
]


That should work.






share|improve this answer
























  • But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

    – Jagjeet Singh
    Nov 13 '18 at 5:27











  • well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:57











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273611%2fdjango-no-module-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Import views like this:



 from .views import * 


You are using class based views so this method will work.






share|improve this answer
























  • tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:54











  • Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

    – Faizan Fareed
    Nov 13 '18 at 18:08











  • actually that was it thank you very much!

    – ahmed cheikh sidahmed
    Nov 13 '18 at 18:24
















0














Import views like this:



 from .views import * 


You are using class based views so this method will work.






share|improve this answer
























  • tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:54











  • Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

    – Faizan Fareed
    Nov 13 '18 at 18:08











  • actually that was it thank you very much!

    – ahmed cheikh sidahmed
    Nov 13 '18 at 18:24














0












0








0







Import views like this:



 from .views import * 


You are using class based views so this method will work.






share|improve this answer













Import views like this:



 from .views import * 


You are using class based views so this method will work.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 6:32









Faizan FareedFaizan Fareed

506




506













  • tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:54











  • Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

    – Faizan Fareed
    Nov 13 '18 at 18:08











  • actually that was it thank you very much!

    – ahmed cheikh sidahmed
    Nov 13 '18 at 18:24



















  • tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:54











  • Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

    – Faizan Fareed
    Nov 13 '18 at 18:08











  • actually that was it thank you very much!

    – ahmed cheikh sidahmed
    Nov 13 '18 at 18:24

















tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

– ahmed cheikh sidahmed
Nov 13 '18 at 17:54





tried it also gave me the File "C:ecommerce-django-mastersrcproductsurls.py", line 2, in <module> from .views import * File "C:ecommerce-django-mastersrcproductsviews.py", line 49 print formset.is_valid() ^ SyntaxError: invalid syntax error

– ahmed cheikh sidahmed
Nov 13 '18 at 17:54













Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

– Faizan Fareed
Nov 13 '18 at 18:08





Your views correctly imported. You getting this error due to not valid syntax. Show your code ? I will check it. print(formset.is_valid()) write in this way.

– Faizan Fareed
Nov 13 '18 at 18:08













actually that was it thank you very much!

– ahmed cheikh sidahmed
Nov 13 '18 at 18:24





actually that was it thank you very much!

– ahmed cheikh sidahmed
Nov 13 '18 at 18:24













0














Change your urlpatterns to this:



urlpatterns = [
url(r'^$', ProductListView.as_view(template_name="product_list"),),
]


That should work.






share|improve this answer
























  • But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

    – Jagjeet Singh
    Nov 13 '18 at 5:27











  • well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:57
















0














Change your urlpatterns to this:



urlpatterns = [
url(r'^$', ProductListView.as_view(template_name="product_list"),),
]


That should work.






share|improve this answer
























  • But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

    – Jagjeet Singh
    Nov 13 '18 at 5:27











  • well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:57














0












0








0







Change your urlpatterns to this:



urlpatterns = [
url(r'^$', ProductListView.as_view(template_name="product_list"),),
]


That should work.






share|improve this answer













Change your urlpatterns to this:



urlpatterns = [
url(r'^$', ProductListView.as_view(template_name="product_list"),),
]


That should work.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 4:36









Hybrid PickerHybrid Picker

138




138













  • But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

    – Jagjeet Singh
    Nov 13 '18 at 5:27











  • well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:57



















  • But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

    – Jagjeet Singh
    Nov 13 '18 at 5:27











  • well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

    – ahmed cheikh sidahmed
    Nov 13 '18 at 17:57

















But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

– Jagjeet Singh
Nov 13 '18 at 5:27





But he has problem in importing views. How he will use ProductListView? It will gives the error ProductListView is not defined.

– Jagjeet Singh
Nov 13 '18 at 5:27













well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

– ahmed cheikh sidahmed
Nov 13 '18 at 17:57





well originally it used to be views.ProductListView.as_view i thought it was the cause of the problem but it did not help that's why i added the first views

– ahmed cheikh sidahmed
Nov 13 '18 at 17:57


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273611%2fdjango-no-module-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues