Django – Series – Post – 2 – return HttpResponse

Spread the love

 

 

Django – Series – Post – 2 – return HttpResponse:

In this blog post we are going to create an app, an app is nothing but an activity which will be referenced in the django project,

The term application describes a Python package that provides some set of features. Applications may be reused in various projects. Applications include some combination of models, views, templates, template tags, static files, URLs, middleware, etc. They’re generally wired into projects with the INSTALLED_APPS setting and optionally with other mechanisms such as URLconfs, the MIDDLEWARE setting, or template inheritance.

It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.

So we will see​​ 

  • How to create an app

  • Define a function in that app and

  • Render ​​ a httpreponse for a http request​​ 

To create an app , execute the below command,

  • python​​ manage.py startup appname

 

 

Create a function home under​​ views.py​​ which will return a http response for a request.

 

 

 

Import the home function from restaurant.views into the project’s​​ urls.py​​ , so when this url pattern is matching it will route the​​ request to the home function.​​ 

 

 

Now if we test the application, it will return the required http response.​​ 

 

 

Thanks for viewing this post, please post your comments below, Please Like and Follow us on facebook​​ 

https://www.facebook.com/gadoth/

 

 

 

 

 

 

==================================

==================================

Related posts

Leave a Comment