Category: Python

Django Queries | Fetch Data From Database | Python Django Tutorial

Hey geek, You have come a long way with us. Till now we were working with django models. We learned how to create models and how to create objects from admin panel. We will discuss how to Create, Update & Delete objects from frontend later. Now we will see how to fetch & filter data from the database.

There are several ways of retrieving data from database. We will execute the following methods:

  • All objects
  • Only One Object
  • A Set of Specific Objects
  • Ordering Objects

Read More

How To Start A Django Project | Python Django Tutorial

Hello Devs, Welcome to the ocean of Web Development with Django. In this blog, we have discussed all the information that you need to know before you start surfing on this ocean. Mainly, we will cover the following topics:

  • What Is Django?
  • Working Architecture of  Django.
  • What is PIP?
  • What is Virtual Environment
  • Creating, Activating & Deactivating Virtual Environment
  • Starting Django project
  • Creating an App
  • Making Migrations
  • Creating a SuperUser
  • The Development Server

What is Django?

Django is an open-source and high-level web application framework written in Python. Django is specially designed by developers with a view to rapid and clean development. A web framework is a package of components that helps developers to develop websites faster and easier without handling low-level details. The framework is named after Django Reinhard, a gypsy jazz guitarist. He was one of the best guitarists of all time.

Read More

Django Class-Based Views | Django Generic Views

Class-based views are basically some pre-defined views that are bundled with django. These are reusable. Django developers felt that they have to write some common views for almost each application. So, they decided to create reusable views which results in Class-Based views. Class-based views (CBV) were introduced in Django 1.7.The reason behind this addition was that using inheritance it would be more customizable than a function-based view.

Read More

Django Models, Python Django Tutorial

We have discussed how to create a Django project and Django app in our first Django tutorial. In this tutorial, we will talk about Django models. We will cover the following topics:

  • Creating a model.
  • Registering Model in django admin site.
  • 'Class Meta' in django models.
  • Creating Objects of Models
  • __str__ Method of django models.
  • get_absolute_url() method of django models.
  • @property in django model.
  • Django Model Fields

Model is a structure for storing data. The model handles everything related to data. Such as: data access, data validation, dealing with data of other models, etc.  It mirrors the fields and behaviors of the data. Generally a model is implemented as a python class which is a subclass of django.db.models.Model. Django gives an automatically-generated database-access API to create a table in our database by each model, and the "attributes" of the table are created by the "fields" of the model class. Models are defined inside an app’s ‘’ file. 

Read More

Unit Testing Graphene-Django API with Pytest – 3 Steps

In modern days, automated software testing is extremely important to kill the bugs during development. Unit testing is the first level of software testing, which a developer can not and should not avoid. Because it helps the developer to write bug-free, secure and robust codes.

What is Unit Testing?

Unit testing is a software testing method where every individual component and every single unit of the software is tested. Most of the time, unit testing is performed by the developer. Some times it is done by a QA engineer.

When you are doing TDD (Test Driven Development), you will write the unit test before starting the actual code. You can also write unit tests after finishing the specific feature. However, unit testing is performed during the coding stage and before the integration test.

Read More

How to build GraphQL API with Django – 7 Steps

What is GraphQL?

Technology is evolving so fast. Every day, old technologies are being replaced by new ones. For many years, REST architecture was dominating web services and APIS. In 2012, Facebook developed GraphQL and open-sourced it in 2015. Since then, it is becoming so popular in the development world. GraphQL is a declarative, strongly typed, data-driven query language to build APIs.

With GraphQL, you can ask exactly what you need from the server with a single API endpoint. Moreover, It aggregates data from multiple related tables and sources going as much deep as needed. In addition, with a strong type checking mechanism, GraphQL helps developers to write more reliable, robust and bug-free codes.

Read More

Page 3 of 3

Powered by WordPress & Theme by Anders Norén