Community Parenting Platform Development and Deployment Using The Django Framework
Community Parenting Platform Development and Deployment Using The Django Framework
240S08
2016
Laxmi Thebe
COMMUNITY PARENTING
PLATFORM
– Development and Deployment Using the Django
Framework
BACHELOR’S THESIS | ABSTRACT
2016 | 44
With the emergence of Information Technology, different tools are being developed and
deployed even with the focus on promoting the wellbeing of people in this particular field. In
parallel with this phenomenon, globalization has taken a new height in this era of information
technology – scattering millions of Nepali people around the globe in search of opportunity.
In the light of the aforementioned context, this thesis project aims to bring thus scattered people
around the globe to their own virtual local community with the noble cause of supporting a child
in their upbringing in their local community by developing and deploying a web application built
on Django Framework including features such as content generation, need declaration, and
sponsorship offers.
This thesis covers the processes of development and deployment of the project, describes tools
and technologies used, and orients towards future development facilitated with inclusion of
scalability issues and security issues. Furthermore, it demonstrates the use of open source
technologies for improving the wellbeing of people.
KEYWORDS:
1 INTRODUCTION 6
1.1 Community Parenting and Nepali context in brief 6
1.2 Project Aim 7
1.3 Author’s Contribution 8
1.4 Thesis Overview 8
REFERENCES 43
FIGURES
PICTURES
1 INTRODUCTION
With the emergence of Information and Technology, the way of our living and
interaction has changed in a way which has brought multitudes of longitudes and
latitudes to intersect in a single point transforming the whole world into a global village.
With this phenomenon, the current wave of globalization is largely fueled and more
than 2 million Nepali people are working abroad in different parts of the world.
This thesis project aims to develop a web application which brings Nepali people from
around the globalized world in that intersection called ‘Community Parenting’ - where
the similar interest of different people from multitudes of intersection of longitudes and
latitudes sponsors children back home in Nepal in different aspects of their necessities.
This thesis discusses the development and deployment process of the thesis project to
its prototype version. Background information related to the project and future
development is included as well to create a smooth transition of personal development
during the thesis development process.
This thesis primarily aims to develop a prototype version of platform as a website using
Django Framework which can be used as a tool to share knowledge to support school
children by creating posts related to the school or village a user of the site belongs to or
to demonstrate sponsorship to support the individual needs of children in Nepal.
Although the concept is developed in the socio-economic context of the Nepal, it is
equally viable as a tool in other developing countries. To achieve the project aim, the
following objectives are set to be achieved:
To conclude the basic concepts of this project based on the breakdown of project aim,
the project aims to involve local people to contribute to the wellbeing of children in their
community back in Nepal by generating relevant contents or offering sponsorship to the
relevant needs of children.
This thesis emphasizes developing a web platform using Django Framework to support
a child in different needs – moreover, the platform can be also used as a tool to
organize activities around a local group. The project, albeit in its preliminary stage,
uniquely combines the different principles of developmental work and strengthens the
position of Information Technology as a tool for humanity. Although the concept is
developed in the socio-economic context of the Nepal, it is equally viable as a tool in
other developing countries as well.
This section of the thesis primarily aims to elaborate the Table of Contents so that
readers can be familiar with the main content of the thesis briefly. The structure and
content of the thesis is described briefly as:
As explained above, the thesis is structured to impart a gradual flow from start to finish
– starting with reflecting the personal and academic premises in the beginning of the
thesis project, and finish including the accomplishment of realization of prototype
version and encouragement for future development.
From the development to the deployment of the project, various tools and technologies
were used. The specific tools used for development and deployment are discussed in
this chapter briefly whereas discussion on the web framework used, i.e., Django
Framework, is included in more details. Generic tools - for example, SSH client for
accessing remote server - are not elaborated as they go beyond the specific focus of
the thesis.
Django is a Python web framework “for perfectionists with deadlines” which is based on
the MVC (Model, View and Controller ) design pattern. Django handles common web
development task, is exceedingly fast and scalable, secure, and incredibly versatile
(Django Software Foundation 2015c) - making it a tool for rapid development of web
application with clean, concise, and maintainable codes.
In MVC design pattern, the models in Django represent the underlying data models in
the backend whereas the templates represent the View. Interestingly and not to be
confused, the view function in Django works as a controller (which can be contested if
Django is said to opt MTV design pattern). Django adopts the philosophy of loose
coupling – where different parts of a system are loosely dependent on each other
hence a single part of the system has a single role which can be easily replaced with
other similar functional components making components orthogonal. The MVC design
pattern also enables loosely coupled models, views, and controllers components. For
example, templates are used to dynamically generate HTML in Django framework –
and other template engines can be used instead of Django’s own template system.
in Django are independent of the Python code that generates view and can be changed
without changing a single line in view codes.
Less code is another Django design philosophy promoting the use of as less code as
possible. Concise, clean and maintainable codes result from the less code philosophy.
Quick development is yet another philosophy which can be summarized with “for
perfectionists with deadlines” tag line. Code repetition is not promoted in Django as
summarized in DRY (Don’t repeat yourself) philosophy. As an example, view
inheritance is the concept in Django where a template which can be repeated in
different pages of the site can be included as a template rather than hard coding in
every pages. Django emphasizes normalization in contrast to redundancy in
development practice. “Explicit is better than implicit” is a core Python principle also
adopted by Django Framework which goes along with other principles nicely. (Django
Software Foundation 2015b.)
A web framework handles common web development tasks as stated earlier. Using
Django lets the developers to emphasize the specific aspects of the application they
are developing rather than implementing the common aspects of web development
frequently. As being a Python Framework, Django also follows Python’s “batteries
included” philosophy hence including features which might not be implemented in most
other frameworks.
Additionally, Django has a great community and good documentation – which makes it
easier for beginners to make their hands dirty by enticing in real project development
tasks. Moreover, it is a widely used open source framework with several third party
packages mostly kept updated. The information about different Django communities
can be found in official Django project site.
As Django adopts DRY philosophy, codes following Django philosophies are concise
and readable. Being a Python framework, it can be deployed in any platform which
supports Python. Such a portability is further enhanced by the use of ORM, i.e., object
relational mapper, so that Django can be deployed with different database
management systems. The popularity of Django framework, availability of Django
developers, and being a widely used established framework pushes cloud providers to
offer support and services for easier deployment of the Django application.
Django also has a built-in admin panel which lets manage the users of the site and
other database objects. It is possible to be familiar with Data Models from Django shell,
and to some extent from the admin panel as it provides an application wise model-
centric interface. In that way, it allows developers and non-technical staff to work
together to develop a data-centric applications (Neuman 2015).
Most importantly, Django is tested and scalable. It is used by some heavy traffic sites
like Eventbrite, Disqus, Instagram, Prezi, Pinterest, Washington Post and other notable
sites. As Django is loosely coupled, different stacks can be unplugged and customized
to fit the specific needs. The development and deployment of this project using Django
framework within the limitation of time constraint is self-evident of Django’s philosophy
‘for perfectionsists with deadlines’ – where fairly challenging projects could be
implemented cleanly, concisely, and efficiently.
An HTTP request from the browser is used to construct the HttpRequest object by the
handler which is passed to the later components. Additionally, the server-specific
handler also handles the response processing. Django has a middleware framework
which intercepts the request/response processing and thus having the ability to alter
Django’s input or output. As an example, AuthenticationMiddleware intercepts the
requests and links them with specific users using sessions (Django Software
Foundation 2015d). As shown in the following diagram, the processing of View is
entirely bypassed if any of the middleware returns HttpResponse. The view function is
the last one to return the HttpResponse in this processing order. Exception middleware
takes control in case of exception in view – which might either return HttpResponse or
the exeption is raised again. Ultimately, if the exception is not handled anywhere in the
processing order, Django provides default views like HTTP 404 and HTTP 500
response.
The view function being one of the important concept in Django web development
concept will be discussed further later in Chapter 4 where returning the HttpResponse
would be evidential in practice.
The last stage of request/response processing takes when the Response Middleware
processes the HttpResponse to return to the browser. Additionally, resources related to
the specific requests are handled by Response Middleware. (Holovaty and Kaplan-
Moss 2009).
During the development process, two tools were used in particular – one of the tool
being used for setting up development environment while the other tool for writing the
code. The tools are described as follows:
Virtualenv: Virtualenv is one of the tool used for development – which creates isolated
Python environments hence addressing the issue of dependencies, versions, and
permissions (Bicking 2014). The project was developed in an isolated environment
created using virtualenv which enabled the author to follow different tutorials developed
using different versions of the same Python packages.
Vim: For the purpose of writing code, the Vim text editor was used in this project. Vim
is a highly configurable advanced text editor which enables efficient editing of the text –
a tool which can be used using SSH communication to the server shell to code the
project. Often known as "programmer's editor", Vim is highly useful for programmer as
it is lightweight and fast providing an easy way to edit text frequently (VIM 2016).
Additionally, Vim is easily available in most of the Linux systems.
PyCharm IDE was one such tools, but the author chose to use Vim as the server was
accessible to anywhere using SSH communication and hence it was easier to use Vim
to write code from anywhere even during very short free time. As said previously, being
lightweight, there was really no need to wait like a minute as in the cases of most IDEs
as a single command vim in the Linux shell is enough to fire the Vim editor
immediately. Moreover, there are so many different plugins for the Vim text editor
which facilitates coding.
The Ubiquity of Vim, different plugins for Vim to assist coding, its efficiency, and its
significance as text editor over SSH terminal session necessiated its utilization during
the development stage.
Different Python packages were used during the development and deployment of the
project and they serve different purposes. Some packages add functionality to the site
whereas some packages are used as a utility tool for different purposes in different
phases of the project development. Some packages add special features which can be
used by other apps or apps written for the project. The following picture displays the list
of packages installed in the virtualenv and utilized for the project during development,
deployment and documentation:
Some of the packages are worth to mention, whereas some utility packages can be
removed as well. For example, a braintree is used to implement online payment –
which is used for sponsoring a student for his or her financial need in the context of this
project. MySQL-Python is used to implement the Django with MySQL database system
– which is a database connector for Python. Pillow is installed so that an ImageField
can be added in Django Models. python-social-auth is used to implement Facebook
login to the system. All the required Python packages were installed using the pip
python package management tool.
This thesis project was developed using Django Web Framework and other supporting
python packages. This web application developed using Django Framework was
deployed in an Apache Server using mod_wsgi and the database back end was
implemented using MySQL database .
Apache Server: The Apache HTTP server is the most used server in Internet which
supports different features – sometimes extending the core functionalities through
compiled modules (one such module being mod_wsgi explained below). It is an open
source software by Apache Software Foundation. In addition to being widely adopted,
reliable, and secure, the virtual hosting feature in Apache was an additional reason for
being chosen for this thesis project as a single web server is being used to serve
multiple sites which are developed using different technologies.
mod_wsgi: It is an Apache module which can be used to host Python web application.
The python web application must support the Python WSGI specification so that the
application can be implemented with an Apache server using the mod_wsgi package
(Dumpleton 2016a).
MySQL: Database systems play a central role in computing – particularly when large
amounts of data are to be handled. Django supports different database back ends but
not all features on all possible back ends. UTF-8 encoding is assumed to be used by
the database back ends in Django. MySQL is a relational database management
system – which means that data are stored in separate tables related to each other and
defined by relationship rules enforced by database management system. It is known
for its speed, reliability and scalability. (MySQL Documentation Team 2016) MySQL 5.5
or higher version of MySQL is supported. A Django’s feature called inspectdb utilizes
information_schema database in MySQL – which is meta-data about database schema
and hence can generate the Django models using the database. Enforcement of
transaction and referential integrity is delegated to the database system by Django. So,
the MyISAM MySQL engine is not able to apply these two features hence the default
engine InnoDB is not changed in this project.
To explain the complete thesis process briefly in term of technologies use, Django
Framework was used as a web development framework with Vim and Virtualenv as a
developing environment so as to deploy later in the Apache server using mod_wsgi
and the MySQL database backend.
This chapter discusses the setting up of the platform for the purpose of development
just before actually starting the coding part. As famously known Django for its niche as
“for perfectionists with deadlines” for the development part, it is relevantly easier to set
up the development environment as well. The virtual environment was set up for the
development in Ubuntu 16.04 known as Xenial Xerus as both development and
deployment took place in the same platform. Additionally, the Django project was also
created before starting to write code as part of the setting up of the platform. The
following sections describe the process to clarify the process further.
The web platform is developed using Python 2.7.12 and Django 1.9, hence, pip was
installed for version 2 of Python. Once pip was installed, virtualenv was installed using
the pip command tool. After installing the virtualenv tool, the new virtual environment
called ‘thesisprojects’ was created in ‘thesis’ directory by issuing the virtualenv
command.
After activating the virtual environment, Django Framework was installed using the pip
tool. As the version was not specified, the latest django version was used for the
development of the porject. Picture 2 verifies the Django version used for this thesis
project.
After installing Django, the Django project called ‘thesis’ was created within the
activated virtual environment using the django-admin command which is a utility tool for
administrative tasks. This process automatically creates a very important utility tool
‘manage.py’ to handle administrative tasks in the project directory. It is important to
note that the ‘settings.py’ file is also created during this process – which contains
configuration for the Django project. In contrast to django-admin, ‘manage.py’ is more
convenient for use as it sets the ‘settings.py’ as the default configuration source file for
the project by setting the "DJANGO_SETTINGS_MODULE" environment variable to
‘settings.py’ with the os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"thesis.settings") command. Moreover, it sets the package related to the project on
sys.path. As this project involves working only with a single Django project and thus a
single ‘settings.py’ file, ‘manage.py’ is better choice to ‘django-admin’ for administrative
tasks. The following picture demonstrates the administrative capability of the
‘manage.py’ script by issuing command to run development server:
After creating the Django project, different Django applications can be created within a
project which are integrated to work coherently as a component of the project. It is
possible that a whole Django site can be developed with a single application within the
project, but developing a project with different applications representing different
components is good design practice. Moreover, as described in Chapter 2, Django
promotes such practices. In practice, the ‘manage.py’ utility is used to create the
application within the project.
In Django application, URL is mapped to the view using URLconf which is defined in
urls.py file. During the creation of the project, a urls.py (set to be ROOT_URLCONF in
settings.py) is added where URLconf for the apps can be imported using include()
function from django.conf.urls. When the requests are received by Django as URL, the
appropriate view is called based on the URLconf to generate response to be rendered
in template. In its simplest form, a Django work-flow consists of defining model, writing
view, updating the URLconf for matching URL to view, and writing the templates.
Database configuration can be setup already or left with the default configuration which
is for SQLite as it is easier to deploy in later phase after the development as well.
For the project, the urls.py file was already created when the project was created with
its own URL space. The apps can have their own URLconf file which can be imported
to the ROOT_URLCONF i.e. URLconf of the project by using include() function. As
apps play an important role in Django development, apps are defined in the next
section; and models being the main component of the data centric apps, the models in
each app will be illustrated with pictures. Views are important but it is inconvenient to
describe all of them, so this paper discussed only briefly whereas URLconf and
urlpatterns will be explained with the help of an example from the project.
The thesis project contains four different apps called ‘posts’, ‘support’, ‘community’ and
‘people’. The app ‘people’ contains custom user information related to this project even
though users are registered using the python-social-auth package when users log in
the site using Facebook credentials. By extending the AbstractBaseUser class from
Django, custom fields are added for the users which are labeled as ‘Member’ in Django
model in ‘people’ app. Thus created models also relate to the UserSocialAuth model
from the python-social-auth package. The posts app is all about creating posts by
‘Member’ in ‘people’ app for ‘community’ or for public in general. The following picture
demonstrates the graphical form of the model in posts app. Django-extensions was
used together with pygraphviz to generate all the model graphs from four different
apps. With Member, Village, and School models, the picture shows one to many
relationship of the Post model.
Similarly, the Member model demonstrated in the following picture reflects the
inheritance of AbstractBaseUser and PermissionMixin class and its relationship with
Village and School models. The other models which are related to Member, i.e., Group
and Permission are resulted as an extension of Django authentication system.
The ‘community’ app contains models which define entities related to community. The
user could have been defined within this app, but our approach to the development
was incremental based on functionalities rather than thorough database modeling in
the beginning. As we started first to make the use of social logins to the site, the app
‘people’ was a result – which we let it be as a user from a community can also
contribute outside of their community and to public in widest possible range. The
models in ‘community’ app are as shown in the picture below. ‘Student’, ‘Requirement’,
‘Village’, ‘School’, and ‘StudentNeed’ are the core models in the community app.
‘Requirement’ is left generic which means a Requirement is not associated only with a
student or a village or a school so that the admin can create the Requirement which
applies for general student needs. StudentNeed is a special model – which defines one
particular need of a particular student but can have multiple sponsors. StudentImage
model is used to save image of the Student which is trivial from the app development
perspective whereas important from the usability perspective. It is noteworthy to notice
the relationship between School and Village with Member – which is labeled as
created_by in the picture – that a School or Village is created by the user who belongs
to the local community. Logically, the users are restricted to create communities
haphazardly as well.
The other important app is ‘support’ as it includes the details about the sponsors and
related information in the context of meeting the need of the student or child. The
models in ‘support’ app are as shown in the picture below:
The Sponser model contains braintree_id which is used for financial transaction using
Braintree payments. Support and SupportDetail are quite confusing, which are like
promise and actions. In Support, a sponsor is recorded who promises to meet the
particular StudentNeed (one need of one student) whereas in SupportDetail event of
the supports are recorded so that a user can sponsor a particular need parallel with
time. It is noteworthy to explain the many-to-many relationship between Sponser and
StudentNeed through the Support model.
Views are like controllers which define what is to be passed to the template for
rendering in the browser. Additionally, it uses form when user input is to be stored in
the database. When an app is created within a project, a skeleton file for view called
‘views.py’ is created inside the app folder – which is edited according to the need of the
app and what the particular app is supposed to do. There are two types of views in
Django – function-based views and class-based views. For the purose of apps, class
based views are used whereas function based views are used in cases like contact
page. Class-based views are good choices when the project becomes larger that
inheritance is needed. Moreover, Django comes shipped with some generic class
based views which can be inheritated to our own class-based views.
The following picture illustrates the function based view which is used to generate
contact page. This view does not use any models, although written in view file
belonging to the people app.
As limited in the number is the function-based view in this project, there are many
class-based views used in this project. The example shown below in the picture
demonstrates StudentCreateView – which inherits the Django offered generic
The view is rendered using the default template name located default location – in this
case, stored inside the app folder in templates/community/ as ‘student_form.html’
where community is app name, student is model name, and _form is
template_name_suffix as shown in Picture 11. The AdminRequiredMixin is mixin which
contains logic to allow only School Admin to do tasks. AdminRequiredMixin displayed
below in the picture can be used in other class based views which needs feature that
only School Admin is allowed to access the page – otherwise it returns a Response
saying ‘you are not school admin – check community/mixins and raise Http404’ which
is the message to generate a good-looking page when access is restricted for a user
who is not School Admin.
Additionally the project uses other mixins as well since they can be useful to class
based views. For example, LogingRequiredMixin is used extensively in this project to
restrict access to some pages if the user is not logged in to the application.
As shown in the template file above, {{form}} tag - which is the default form name in
context - is all needed to render the form in the response where {{form.as_p}} is form
rendering option where each element of form is displayed within paragraph (<p></p>
tags). The picture ‘StudentCreateView rendered’ below demonstrates how the template
from above is rendered in browser to the School Admin.
In conclusion, the function-based views are simple – they use method decorators for
what mixins do in the class based views and always return HttpResponse object.
Class-based views are convenient approach to writing views in Django, yet it takes
time to become familiar with base classes shipped with Django to start working coding.
The concept of context is also important to note in the case of view whether it is
function-based or class-based views. Django compiles the template once and contains
variable names within double curly braces. In the template example above (Picture 11),
for example {{form}} is such a variable – which is passed to the template as dictionary
variable containing ‘key’: ‘value’ pair. The class-based view – as it uses the base class
shipped with Django – does not define the context of its own and uses the inherited
one (Picture 9) whereas the function based view declares {‘errors’:errors} as context
(Picture 8 – line 84). Finally, as described in Section 4.5, these views are invoked by
Django once it matches the URL request sent by browser to the urlpatterns in URLconf.
Comparing the form fields defined in the Meta class in StudentForm above in Picture
13 with the model fields in Student below in Picture 14, all fields are not displayed in
the form when rendering in the browser. Some fields are set during the view
processing, whereas some fields are set automatically; and some fields can be optional
as well.
In conclusion, a number of forms are used in this project. Some model forms are
generated on the fly – for example, when editing or adding the student needs, a
logged-in Student Admin sees only the students from his school which was only
possible by generating the form on the fly. Additional complexities can appear in form
handling when there is a needs for some customization – for example, when form fields
validation is dependent on each other (for example, the user can not have the same
password as their email). The form described in this section appears to be easy
although it can be slightly daunting for the beginners when customization is required.
For example, generating a model form on the fly was new in this project and took some
time to deal with that issue.
Web pages are associated with the URL. When a user enters the URL in browser, this
association between page and URL is the way Django knows what page to serve for a
particular request. URLconf in Django is a Python module which Django uses to match
the requested URL with the correct view to be served. Django uses regular expressions
to declare URL patterns and proceeds in the pattern from top to bottom when a request
comes until it finds the first match where it stops further processing of the pattern.
The following picture demonstrates the URLconf file for the ‘people’ app.
Django uses the following algorithm to figure out what page to serve:
The urls.py file in the above picture from the people app is imported in the
ROOT_URLCONF file (created when the project was created in the beginning). The
following picture reflects the import in line 27 so that Django can access to the
urlpatterns defined in apps.
In this way, the urlpatterns defined in different apps is visible to the Django – hence
urlpatterns can loosely hold different components together in this specific aspects of
the development process.
There are URLconfs in other apps as well and the basic way of writing URLconf is the
same. The above URLconfs file also demonstrates the use of arguments which are
passed to the views as described in the above described algorithm.
The thesis project was deployed in an Apache Web Server using mod_wsgi. The back
end data was stored using the MySQL database management system. The following
sections describe the setting up and configuration of the deployment process in detail.
mod_wsgi can be installed also with pip - a package management system used for
installing and managing python packages (Python for beginners 2012) - command
which generates configuration automatically; however for this project, the traditional
approach of installation is opted where Apache is configured to load mod_wsgi
manually. The source code in tar ball form was downloaded using the wget command
and unpacked as:
As noted in the Google project page of the module, the apache2-dev package was also
installed as in this case the apache was installed from package repository issuing the
‘sudo apt-get install apache2’ command in the Ubuntu server (Dumpleton 2016b).
The unpacked source code was configured with the ./configure command; the package
was built with the make command and then installed in standard location by issuing the
make install command – the location being dictated by Apache for its modules. The
error log reveals the presence of mod_wsgi as highlighted in the picture above. After
confirming the presence of mod_wsgi, the Apache server was restarted with the ‘sudo
/etc/init.d/apache2 restart’ command and the ‘make clean’ command was issued to
clean up after installation. The downloaded tar ball and unpacked source files were
deleted.
The virtual host configuration was updated to include the line 1 as shown in the figure
below to load the mod_wsgi module. Additionally, the figure includes the complete
virtual host configuration for the site which includes the implementation of HTTPS
protocol for the secure communication between clients and the server. Note that there
is only a single WSGIDaemonProcess defined for both HTTP and HTTPS as they run
within the same daemon process.
After completing the VirtualHost file, the site was enabled and the Apache server was
restarted again to bring the change to effect.
For the deployment of Django with MySQL, the MySQL server was installed in the
machine and the database called ‘meroserofero’ was created for the project. Moreover,
practices for hardening database security were implemented as described later in this
chapter. In the Django project’s settings.py file, the database engine was set to be
MySQL and the database access configuration was imported from another file as
shown in the figure below:
The database access configuration pointed above is as shown in the figure below. The
password is masked to hide it from the readers. The default character set was set to be
utf8 – which has briefly been discussed previously.
The package mysql-python was installed using the pip tool which is a Python interface
for MySQL database i.e. database connection library. The development package files
for database called libmysqlclient-dev were required to install in the system in order to
successfully install the mysql-python package in the virtual environment. After the
process of deployment, the following security measures were considered.
Security practices were adopted partly during the development and mostly during the
deployment of the platform. Although the project is in its prototype version, the project
in its nature is to be secured – particularly when it involves information about
vulnerable people and financial transactions. For this reason, security requirements of
the application were highly considered and the following measures were implemented:
In the project settings.py file, DEBUG = True was changed to DEBUG = False. Settings
Debug on with the DEBUG = True option is only recommended during the development
phase. In addition, the DEBUG = True option is also resource-consuming. For
example, database queries will be saved in memory.
Host header validation was set in Django using ALLOWED_HOSTS setting. Actually,
when DEBUG is set to False, it is necessary to set this option. In our case, it was set to
be meroserofero.org as this domain is being served. This is a security measure against
HTTP Host header attacks. (Django Software Foundation 2015a.)
The SECRET_KEY was not kept in settings.py file, rather it was saved in file and read
from the file.
ADMIN was set in settings file – so that any error is reported by the Django site to the
admin.
Regarding the security issues within the application, user privileges were used to limit
the permissions for different users. To protect from cross site request forgery, Django
provides the template tag which is used in all forms submitted from the browser using
POST method. Only admins are allowed to create Student Profile – and normal users
are only allowed to create posts and be sponsor. Financial donations can be offered
even by anonymous users without logging in with Facebook logins but by providing an
email address. One can only propose to be sponsor – and demonstrates that he or she
is interested by paying certain amount of money (at the time, it is set up to be 1 dollar).
Such requests are recommended for evaluation by the admin of the site (which can be
also handed over to admin of the group i.e., school or village) so that the student needs
For more information, security issues related to Django can be viewed by following this
link (https://docs.djangoproject.com/en/1.9/releases/security/) which is the archive of
security issues.
Databases have been the integral component of the websites and are of utmost
important for data-centric sites. Because of such importance, the security of the
database of this project was highly considered during the deployment of the project.
Regarding this project, MySQL security was hardened using the following practices
under consideration during the deployment:
After securing the deployed system, scalability issues were considered as illustrated in
the following section.
For a project that aims big, scalability is equally important as security. Sometimes the
performance overhead comes from latency in communication with other services.
Cache could be implemented if application scales to such level. Varnish can be
implemented – which is a piece of software with the ability to cache entire HTTP
response hence able to serve response for particular request quickly and efficiently
even without forwarding the requests to the Django server (Robenolt 2013).
The codes could be improved – for which Django Debug Toolbar can be used to fine
tune the performance. It definitely involves significant mastery which the author is yet to
develop.
Database sharding could be implemented if the data signifcantly grows. For example,
data related to a group (in our case, either community or school) could be stored in a
single database. Another option regarding scaling database would be MySQL
replication – where Django can be configured to query inserts and updates to the
masters and selects to the slaves (Shuping 2014).
The configuration of the deployment droplet (which is a virtual private server) could be
increased when the traffic to the application grows.
As discussed in previous section, the endeavor of thesis project was to develop and
deploy a Django web application to create community platform for supporting children
upbringing in Nepal. The deployed version is available at https://meroserofero.org at
the moment with the intention that it will be available in the same domain after the
future development. The demo version of the project demonstrates the basic
functionality out-lined in description of requirements. After completion of the
development process, there were some issues encountered which need to be
neddressed during the future development which are elaborated further in following
sections.
6.1 Recommendation
Even though the project looks promising, there is much works to be done as well. For
example, the issue of scalability is yet to be addressed – at least so that around two
million people can be a user and approximately 10 percent of them would be using
simultaneously as around two millions Nepali people are abroad. Pages which are
static – for example, the ‘About Us’ page in the context of this project could have been
served statically from the Apache server rather than passing through Django
request/response process. Moreover, there are many usability issues which are to be
addressed. One of the important ones is the login page – rather than using the
homepage as login page, we could create some pop up window or a single page. Ajax
functionality could be added in some of the graphical components as well. Regarding
the web application itself, there is a need to redesign the overall architecture as well
from the experience that is accumulated over the time. The approach to the design was
to add functionalities incrementally from the beginning rather than starting up from
planning – which is quite understandable as being the first time involvement in project
of such scale with product as a basic requirement for the successful completion of the
thesis. In the context of the development, we could also add features, such as project
where activities that involve the well-being of the target group could be planned.
Obviously, there are several promises as it is just the beginning of the project. Mobile
application could be also implemented where the same backend could be used to
serve data using REST API packages developed for Django Framework. Django
philosophies could be also used carefully – for example, DRY philosophy was not
followed strictly when writing templates where template inheritance could have been
used. Coding incrementally from the beginning was also the reason why there are
some code repetitions particularly in templates. Testing is also an important aspect in
web development which is also a missing part in this project. For learning purposes, it
would not be recommended to use Facebook social plugin for comments. Yet, it was a
preferred choice as users are logged in only using Facebook social login mechanism.
The login mechanism could be also extended to include other services, such as
Google, Twitter and others. In spite of these developments yet to be achieved,
personal development was satisfactory as described in the next section.
Being the first endeavor in web development, the author has significantly gained skills
related to web development on one hand; on the other hand, there are aspects to be
developed further. The most important development is confidence to work in software
projects even with no prior knowledge. Moreover, the author realized the importance of
staying a bit longer sometime on the task at hand. Time management might be an
important aspect in real life projects, but giving whatever time left for the working on the
thesis proved to be significant on the thesis process. In the context of the technologies
used, the author became familiar with Bootstrap front-end technology, with JavaScript
to some extent, and with Django framework and Python programming in general. There
were times when trying to figure out a single problem took hours, yet it was of immense
satisfaction to get things done. Last but not least, the deployment of the project in the
practical world helped to improve the skills with Linux server administration and other
web domain related skills.
our own needs or at least a perspective to use tools relevant to our own context. This
thesis projects in itself might be of less significance at the moment, but it sheds light on
the strong possibility of open source technologies to transform the way of our living in
Nepal.
REFERENCES
Dumpleton, G. 2016 (b). Summary Quick Installation Guide for Mod_wsgi. Consulted
22.08.2016
https://code.google.com/archive/p/modwsgi/wikis/QuickInstallationGuide.wiki#Apache_Require
ments.
Holovaty, A. & Kaplan-Moss, J. 2009. The Definitive Guide to Django : Web Development done
Right. Berkeley: Apress.
Kaphle, A. 2014. Nepal, once known for farming, now exports people; migrants earn big but
face risks. Consulted 21.07.2016 http://wpo.st/zqp02.
Neuman, E. 2015. "Ten Reasons Django is Perfect for Startups. Consulted 20.08.2016
http://learn.onemonth.com/ten-reasons-django-is-perfect-for-startups.
Python for Beginners 2012. How to use Pip in Python?. Consulted 11.08.2016
http://www.pythonforbeginners.com/basics/python-pip-usage.