0% found this document useful (0 votes)
14 views

Use of Django Framework

bdbddnnffnfkfknfndndohdheheja

Uploaded by

ikhtiyor442b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Use of Django Framework

bdbddnnffnfkfknfndndohdheheja

Uploaded by

ikhtiyor442b
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

The Introduction of the use of Django Framework in the real project

Overall, Django is a modern programming language among other frameworks, which is quite
popular while working with it. Besides, it composes a strong advanced security system most
frameworks might not have. One possible feature is that there is no need to rebuild wheel again
as Django focuses on a hassle of web development. In fact, there is a real project (named GP-
SOFA shopping system) we made to describe Django and its connection with the front-end.

Additionally, in case of need to initiate and run a server, Django comes with a help for us to run
a lightweight webserver by getting our code worked and checked quickly, without a need to
spend time for configuring a server. When we run the Django development server, it keeps
checking for changes in our code. It reloads automatically in this project, freeing us from
manually reloading it after code changes. However, it might not notice some actions, such as
adding new files to the project, so we had to restart the server manually in these cases. We are
able to start the server by typing the following command from the project's root folder:
After typing: python manage.py runserver

after little time, we are to see the result below (in our project):

Figure 1: Successfully running the site built in Django

This log or message, an example, forwarded by a server is an obvious possibility to open our
server via link localhost or 127.0.0.1 IP.
When we lunched it successfully, we saw a picture depicted below.

Figure 2: Having loaded the site, The picture was observed (No errors)
Is it necessary to delve into settings?
So as to keep a track of the application and be able to create new functions or databases and load
it successfully, it is all-important that we activate settings, otherwise there can be a chaos, or
some apps can work conversely, resulting in them and other systems not to be able to work
properly during the use of them. To avoid those issues, we had addressed to edit and add some
particular functions we want towards the settings.py, namely INSTALLED_APPS that was
altered as we willed.

Figure 3: The part of the settings, namely INSTALLED_APPS in the project

Here on the depicture, specifically Figure 3. There are numerous fields we added to be able to
work on them, including their features.

Django Administrator form in the real project

One of the most influential parts of Django is the automatic admin interface. It can load and read
metadata from our models to provide a quick, model-centric interface where admin-users can
control content on the website. The admin’s use of access is limited to an organization’s internal
management tool. It was not planned for constructing our entire front-end around.
Besides, models we added to monitor were displayed with respect to heading parts (named
BASE or ORDER, ...). Evidently, we loaded this page by putting http://127.0.0.1:8000/admin/
website to our console, which permitted us to load our private site situated in the localhost. It is
apparently feasible to see the ‘admin control’ page after having passed through a login section
successfully. A real example is shown, namely Figure 4.

Figure 4: Real admin control interface in the project


After that we can alter/add/delete the information of each module, let me take one quintessential
example that is pertained to only ‘Colors’ model that can be supervised by admins, which is
pictured on the Figure 5:

Figure 5: Model ‘Colors’ that can be altered totally

That said, there should be people who are much painstaking to prevent any damage to the server
inasmuch as it might be crashed, especially with DDOS attacks or other ones. Thus, this admin
model, ready one, in Django is much secured for both, users and admins.
Furthermore, to implement and create the model ‘Colors’ in Django admin, there is a need to
write lucid code which is responsible for loading it. That is why, we have written the code that
was straightforward and also responsible to do so (Code #1).

--- Code #1

@admin.register(models.ColorModel)
class AbstractColorModel(admin.ModelAdmin):
list_display = ['get_absolute_names', 'get_color_on_background']
list_per_page = 8

As regards the rest of others, login and register sections. I had been demanded to make specific
page in our site. After that, I devised the page by which users may log in or register with a clear
way. This page based on the file named ‘login-logout.html’ was controlled by views.py, also was
based on CSS, if user registers or makes an effort to log in, shown in the figure 6.

Figure 6: Login and registration through the real website


Reference to working with QuerySets in Django
It is obviously pivotal to work with QuerySets which can become handy for certain states. For
instance, whenever we have a fully functional administration site to manage our content, it's time
to explore how to retrieve information from the database and interact with it. We have done this
as without it, there is no point to load the project because everything, models and information, is
preserved in Database.

Also, Django comes with a powerful database abstraction API, which lets us create, retrieve,
update, and delete objects easily. The Django object-relational mapper (ORM) is compatible
with MySQL, PostgreSQL, SQLite, Oracle, and MariaDB. We must recall that we can define the
database of project in the DATABASES setting of settings.py file of our project. Django can
work with multiple databases at one time, and we can program database routers to create custom
routing schemes. In practise test, we could notice the significance of such a code pertained to
Databases and its load (Code #2).

--- Code #2

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

When it is done (Code #2 embracing SQLite 3), there will be a possibility to be able to make use
of Django models. Once we have created our data models, Django gives us a free API to interact
with them. The Django ORM is based on QuerySets. A QuerySet is a collection of database
queries to retrieve objects from our database. We can apply filters to QuerySets to narrow down
the query results based on given parameters. As far as it is concerned in the project, we were
assured to be careful on them since information saved in Databases might be diverted or deleted
easily in case there is no precaution made in advance.

Figure 7 located left side. The models,


Banner and Brand, were devised to make
them possible to be used while retrieving
and forwarding their information.
Utilization of migrations
In order to load our data or files we would like to get them worked in our site conveniently, there
should be migrations for those. After having finished with details of photos or trivial private
stuff of a project minutely, we made a migration before loading the site as we might be able not
to monitor what we will. To do so, there was an example, there is a data model for the blog
posts, we needed a database table for it. Django comes with a migration system that tracks the
changes made to models and enables them to propagate into the database. As mentioned above,
the “migrate” command applies migrations for all applications listed in INSTALLED_APPS; it
synchronizes the database with the current models and existing migrations. Primarily, we were in
need of creating an initial migration for our models. If we did not do so, we could not migrate,
which would lead the media files not to get saved and loaded automatically. Whereupon, there
was a need to write a command which was responsible to tackle the issue (console code #3)

--- Console Code #3


python manage.py makemigrations media

There should be the following output:

Migrations for 'media':


brand/migrations/0001_initial.py
- Create model Brand

In conclusion

I was the project leader involved in a group having had several people since we commenced a
project (named GP-SOFA). I was not only a person supervising my colleagues and also
programmer making plans beforehand to back my team with my ideas so as to tackle problems
connected to specific topics, especially programming.

Figure 8. Thanks to my team, I became much more skilled in


contrast to in the past and now capable of working with
others. Interestingly, even though I had been not used to
making a logo of companies, I was able to create it finally by
myself. Of course, it is because of effort of my team and mine.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy