Install Django REST Framework on Ubuntu

django dashboard

Django REST framework is a powerful and flexible toolkit for building Web APIs. Some reasons you might want to use REST framework: The Web browsable API is a huge usability win for your developers. Authentication policies including packages for OAuth1a and OAuth2. Serialization that supports both ORM and non-ORM data sources. Customizable all the way … Read more

Solved: DisallowedHost – Invalid HTTP_HOST header

This error is related to “Installing Django and Django-REST Framework on ubuntu” , if you have Django application / server running on local ubuntu host as, Then this server is started with binding to your local loopback IP address and default port as, Now, when you decide to use your IP address instead of local … Read more

Developing first REST API using Django Rest Framework ( DRF )

This post is in continuation with our previous post “Installing Django and Django-REST Framework on Ubuntu for developing REST API’s” which setup the development environment required to start developing rest API. The final step in setting up your virtual environment is to activate it: Now, we need to install “django” and “django rest framework” using … Read more

How to set / change the timezone in Django ?

If you have followed to create your first django project “Starting webserver using your first simple Django project” , the default timezone “TIME_ZONE” argument is set to “UTC” as we can see in “my_django_project/settings.py” Now, if you want to change the Time zone check the corresponding “TZ Database name” string from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and modify “TIME_ZONE”, … Read more

How to solve Django Bad Request 400 error ?

When you tries to do http post with a JSON data / payload to your Django REST Framework ( DRF ) based server, sometimes you may get the “Bad Request” error with http code 400 as below, When we checked what is the meaning of this error from Django documentation, it is defined as, “The … Read more

How to define different urlpatterns in view.py for Django

As we have seen in our previous post “Developing REST API using functions in DRF application views” we defined two URL’s, http://127.0.0.1/users https://127.0.0.1/user/user_primary_key => example : http://127.0.0.1/user/2 The first URL, “http://127.0.0.1/users” is mapped with view in url.py with urlpattern and in view.py as function “users” as, The second URL, http://127.0.0.1/user/2 , where 2 is the … Read more

What is routers in Django REST Framework ?

As we have seen in our previous post “Developing REST API using functions in DRF application views” , we were able to do http POST with the data and GET the same data to view in JSON format. Also, we tried to understand, how urlpatterns from url.py are used to distingush different URL’s and also … Read more

How to add Model to Django admin dashboard

ui

By default when you login to admin dashboard, http://127.0.0.1:8000/admin/ you will only see “Authentication and Authorisation ” options which allows you to create Groups and Users.. like below Now, as we have written in “Writing first model for your Django App” if we want to make sure the Model “Question” from polls app, i.e. polls/model.py … Read more