On Mon, Feb 5, 2018 at 10:59 AM, sarvit sarvit <[email protected]>
wrote:
> is not app
> views.py
> from django.http import HttpRequest
>
> def index(request):
> return HttpRequest("Hello World.")
>
> urls.py
>
> from django.shortcuts import render
> from django.conf.urls import url
> from django.contrib import admin
> from django.urls import path
> from views.py import views
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> url(r'^$',views.index),
>
>
> ]
>
>
>
Judging from this, you are trying to import the views from your "main"
urls.py, and generally the views are within an django app. In that case,
you should use your_app_name.views as stated before. "Relative imports"
(from . import views) will work only if the file is on the same directory
you are working (i.e. inside an app).
.
>
>
> On Monday, February 5, 2018 at 4:54:59 PM UTC+3:30, sarvit sarvit wrote:
>>
>> Hello
>> I importing error
>> Please help me
>> from django.shortcuts import render
>> from django.conf.urls import url
>> from django.contrib import admin
>> from django.urls import path
>> from . import views
>>
>>
>> Traceback (most recent call last):
>> File "c:\Users\saeid\Desktop\sade\env\Post\Post\urls.py", line 20, in
>> <module>
>> from . import views
>> ImportError: cannot import name 'views'
>>
>>
>>
>> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/1d3b5804-123c-40ce-9ec9-fa4bb5fc8495%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1d3b5804-123c-40ce-9ec9-fa4bb5fc8495%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/CA%2BFDnhLCgR_6AjyYXSZ8Nu%2BOpkQnLsLaCpUkBSJ21Ekuw39Baw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.