Friday, September 18, 2020

how to create url helloworld

*file views.py in folder pages

from django.htpp import HtppResponse
from django.shortcuts import render

# Create your views here.
def home_view(*args, **kwargs): # *args, **kwargs
    return HtppResponse("<h1>hello world</h1>")  


C:\Users\leo>C:/python37/python.exe c:/python37/Try-Django-master/src/pages/views.py
Traceback (most recent call last):
  File "c:/python37/Try-Django-master/src/pages/views.py", line 1, in <module>
    from django.htpp import HtppResponse
ModuleNotFoundError: No module named 'django.htpp'

from django.htpp import HtppResponse
from django.shortcuts import render

*files urls.py 

from django.contrib import admin
from django.urls import path

from pages import views

urlpatterns = [
    path('', views.home_view, name='home'),
    path('admin/', admin.site.urls),
]

file setting
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # third party
    # own
    'pages',
    'products',
]

error :   
File "C:\python37\Try-Django-master\src\trydjango\urls.py", line 19, in <module>
    from pages import views
  File "C:\python37\Try-Django-master\src\pages\views.py", line 1, in <module>
    from django.htpp import HtppResponse
ModuleNotFoundError: No module named 'django.htpp'

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ce82a275-88ba-49eb-9a09-8f19b22dcb75n%40googlegroups.com.

No comments:

Post a Comment