Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django return string from URL dispatcher

Tags:

django

Is there any way to return 'hello world' string from bare django project (without creating app and views.py)?

Something like this:

urlpatterns = patterns('',
    url(r'^$', plaint_text_module, 'Hello World!'),
)
like image 964
Ali Ismayilov Avatar asked Mar 08 '13 17:03

Ali Ismayilov


1 Answers

You can add inline lambda (or view callable for that matter):

from django.http import HttpResponse

urlpatterns = patterns('',
    url(r'^$', lambda request: HttpResponse('Hello World!'), name='hello_world'),
)
like image 98
miki725 Avatar answered Nov 08 '22 19:11

miki725