A
A
ahmed_al_asad2016-09-25 15:20:40
Django
ahmed_al_asad, 2016-09-25 15:20:40

How to pass a function from views to urlpatterns?

I am using django version 1.10. We need this function from views.py:

from django.http import HttpResponse
from django.shortcuts import render


def post_home(request):

    return HttpResponse("<h1>Hi</h1>")

Pass craft urls.py:
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^posts/$',  "НАДО СУДА ПЕРЕДАТЬ ФУНКЦИЮ"),
]

I searched on the official documentation, nothing is clear there.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question