Use of Django Framework
Use of Django Framework
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):
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.
Here on the depicture, specifically Figure 3. There are numerous fields we added to be able to
work on them, including their features.
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.
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.
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.
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.