First, let's understand what a full-stack application is. A full-stack application is a fully-fledged web application that is interactive for users and facilitates machine interaction. It involves storing, manipulating data, and retrieving information based on user requirements.
To create such a web application, individuals need a comprehensive skillset that encompasses both frontend and backend development.
Drawing an analogy to the human body, a web application can be likened to our physical form. The elements a user directly interacts with - the skin, hands, eyes, and mouth - equate to the visible and tangible components of an application, commonly referred to as the frontend. It encompasses what users see, touch, feel, and interact with.
In the context of communication, a person speaks through their mouth, but the thoughts and words originate from the brain. Similarly, in a web application, the backend serves as the metaphorical brain. It dictates how swiftly the system responds and manages the knowledge it retains.
The landscape of full-stack development is diverse, with several frameworks available in the market. Some of the most popular frameworks include:
Most popular frameworks are:
Each framework comes with its own uniqueness and ability to perform and serve the client as well as developer ease to create application. At AiDOOS, we leverage the Django framework for effective data manipulation and management. Complemented by React as a supporting hand, we ensure a seamless frontend experience for our users.
Why did we choose Django? As the creators of Django asserts “The web framework for perfectionists with deadline”.
We require the application to build quickly but with quality as well as security that’s one of the reasons we chose Django. It’s a developer friendly framework to build application which can be built quickly and scale easily.
Just a quick fact the popular social media platform Instagram also developed in Django tech stack as well as the Threads platform (Copy of twitter) which is developed under 6 months also uses same Instagram tech stack which is Django, Now you can evaluate the strength and agility of Django framework
We chose React at AiDOOS for its excellent handling of intensive user interactions, particularly beneficial for tools in our web application. However, we faced two challenges: the initial loading time of the React module and the impact of client-side rendering on SEO effectiveness.
AiDOOS utilizes Django Rest Framework to create smooth APIs, connecting React with our Django application
- Django is a framework which follow MVC architecture (Model-View-Controller).
- Django Models are the representation or we can say abstraction of SQL tables.
- With Django models, it is very easy and convenient to handle SQL queries with the help of Django ORM (Object Relational Mapping), - With the help of makemigrations and migrate commands, it is very easy to make changes to the table structure as well.
Django View in M.V.C. structure is related to the frontend representation of the application where the user interact with the application in Django the frontend layer is stored default inside templates/ folder and all the view related file mentioned as templates. Django has its own templating engine
Django Controller now when we talk about the controller, controller are the place where all the business logic is written it is the middle layer between Model and a View, but in Django these controller are called as views.
The other feature of Django which is particularly distinctive and captivating is:
Django signals are like little messengers that let different parts of a web application talk to each other. They help one part of the code notify another when something happens, for an example a record has been deleted from table then a through signal we can
write a logic what we have to do we that record is deleted.
With Django’s BaseCommand class you can write custom command to do specific tasks and run logic accordingly, you can use your custom commands to run batch jobs which we usually do in AiDOOS.
Django admin’s is one of the most lucrative feature from Django it Is so easy to create a admin dashboard and list all your model their, it’s a boon for operations team as well developer’s perspective because you don’t have to worry to spent time to create a admin dashboard for your operation team at the starting stages of your organization if its small Django admin proves to be quite useful.
we have talked enough about Django lets create an application in Django example a Feed posting application where user can post feed and other users can read the feed as well comment on those feed.
First, we will create models. Using Django's inbuilt User model class, you can create your users. Django also provides security through user authentication using its session authentication class, which you do not have to write explicitly.
Now the user has been created its time to create Post model. A Post model will have different-different attributes major ones in my opinion is
This is a basic Post model now we will create Post Comments model where we can store post related comments
PostComments model:
Next step is to write the views which will handle all the business logic:
We can use either Class-based views or function-based views depending on various contexts. Let's consider an example of writing a view to retrieve all the posts for the feed. In this case, we will use a Class-based view that inherits from Django's View class. The ORM query to retrieve the data could look like this:
“posts=Posts.objects.all()”
This ORM query is equivalent to "SELECT * FROM posts;".
Moving on to the view, we need to write URL patterns to access this view. The view will return a response, and within that response, an HTML template will be included. You can style your template and utilize static tags to call static images and CSS files.
Now that we've completed the three layers—models, views, and templates—it's time to run the server. However, before doing so, we shouldn't forget the crucial step of makemigrations.
This command generates migration files for our application, responsible for instructing Django on how to manipulate the database structure (Data Manipulation Language or DML).
After creating these migration files, we execute the migrate command, which works its magic to apply the changes and populate our database.
Once these database operations are in place, we're ready to run the server. Use the runserver command, with the default Django server port being 8000.
Congratulations! You have successfully created your first full-stack application. Best wishes for your future endeavours.