How to Build a RESTful API using the Django REST Framework

The Django REST Framework (DRF) allows you create REST based APIs quickly and simply, providing a range of features such authentication, error handling, serialization and full CRUD  (Create Replace Update Delete) based operations to your database. Within this article will look at how to create a very basic API. The API will take in a … Read more

Django+MongoEngine – How to Perform an Update_or_Create Action

BuiltIn ORM Django provides a convenient method when needing to update a model instance, but create if it does not exist. The method is shown below, update_or_create(defaults=None, **kwargs) However MongoEngine replaces the builtin object-relational mapper (ORM). Because of this an alternative is required. MongoEngine Within MongoEngine the modify method can be used to achieve the … Read more

How to Configure Celery within Django

Celery is an open source asynchronous task queue/job queue based on distributed message passing[1]. Within this article we will provide the configuration steps requiring for installing celery within Django. Our tutorial Example Broker Within this example we will use Redis as the broker. Celery uses a broker to pass messages between your application and Celery … Read more

Django Application Design Framework

app-design

Components MODULES Modules should be installed via pip, including modules from github. To install modules from github the following article describes the steps involved. Structure projectx |– app1 | |– __init__.py | |– models.py | |– views.py |– app2 | |– __init__.py | |– models.py | ‘– views.py |– appx | |– __init__.py | |– … Read more

Django Quick Reference

Quick Reference Models Query Description Event.objects.filter(appid=”example”) filter for appid eq example Event.objects..exclude(username=”rick”) show everything not excluding username eq rick Event.objects.filter(appid=”example”).exclude(user__in=[“bob”,”fred”]) include appid eq example and exclude user bob or fred Upgrade.objects.filter(device_number=’device_numberooo’).values() Display as dict() Management Commands Commands Description  ./manage.py dumpdata updowngrade –indent 2       http://stackoverflow.com/questions/14115318/create-django-model-or-update-if-exists 

Django 1.5 – ‘url’ requires a non-empty first argument.

Issue When running Django 1.5.1 you may observe the following error, NoReverseMatch at /‘url’ requires a non-empty first argument. The syntax changed in Django 1.5, see the docs. Solution This issue can occur due to changes in the url tag syntax. More information on this can be found at  https://docs.djangoproject.com/en/dev/releases/1.5/. The correct syntax for url … Read more

Django – How do I create a custom login page ?

Within this article we will look at how to permit only authenticated users to a view via the use of a custom login form. SETTINGS First of all a few changes need to be made to the settings.py file. Such as + ‘django.contrib.auth.middleware.AuthenticationMiddleware’ to MIDDLEWARE_CLASSES + ‘django.contrib.auth’ and ‘django.contrib.contenttypes’to INSTALLED_APPS Once done update your database by … Read more

Django – How can I pass a string from a URL to a view ?

Within Django the are 2 ways of using a URL parameter within a view. They are via URLConf or by using request.GET. URLConf With this method the URLConf file is configured to define your URL parameter via the use of regex. Say that we have a URL that is ‘www.domain.co.uk/user=value’ and we want to grab … Read more

How do I use AJAX along side Django ?

Introduction Within this example we will show you a simple example of how to integrate AJAX with Django. AJAX (Asynchronous JavaScript and XML) is a technique that provides the ability to update parts of a web page, without reloading the whole page. Now days,  typically JSON is the preferred method over XML due to JSON`s … Read more

How do I configure Django to serve my Robots.txt file ?

Within this article we will look at how to configure Django to serve your ‘robots.txt’ file. Though there are a number of methods available to achieve this, this example we will only look at the Django urls.py method. In that only the the urls.py file within your Django project will need to be changed. Example … Read more

How to serve multiple domains from within a single Django project

Introduction Within this article we will be showing you the necessary steps required to serve multiple domains from within a single Django project. This example will based upon a project named ‘myproject’ and 2 domains named ‘domain1’ and ‘domain2’. Below shows the file structure. /opt/`– django    |    `– myproject        |– __init__.py        |– domain1        |   |– … Read more

Joomla – JFolder::create: Could not create directory

When running Joomla 2.5 you may observe the following error : JFolder::create: Could not create directory Solution This error is typically related to permissions. To resolve the issue run the following commands (replacing the path with the path of your Joomla installation). cd /var/www/html/joomla-sitefind . -type f -exec chmod 644 {} \;find  . -type d … Read more

How do I configure Apache to serve my Django website ?

Summary In order for Apache to serve your Django website WSGI is configured. The Web Server Gateway Interface (WSGI) defines a simple and universal interface between web servers and web applications or frameworks for the Python programming language (wikipedia). Note : The following steps are based on a Linux Centos based distro. The following steps within … Read more

Django – Static Files

Static Files is a Django app that helps with serving static content. This tutorial is meant as a short and quick guide on how to configure your Django project to serve static based content.To achieve this we will configure Django (via settings.py) and Apache. Our example will be based on serving static content from the … Read more

Django – CSRF verification failed. Request aborted.

Issue When trying to access your Django site within CSRF configured you receive the following via a Forbidden (403) HTTP error message: CSRF verification failed. Request aborted.No CSRF or session cookie. Solution In my scenario I found that the order of settings.MIDDLEWARE_CLASSES was incorrect. Below shows you an example settings.py MIDDLEWARE_CLASSES = (    ‘django.middleware.csrf.CsrfViewMiddleware’,    ‘django.middleware.common.CommonMiddleware’,    … Read more

Joomla – How to add a custom field

Within this tutotial I will show you the nessecary steps required to add a custom field named ‘Version’ to your Joomla site. This field will be displayed within both the administrator console and the published article. 1. Configure Database Within phpmyadmin run the following SQL command ALTER TABLE `jos_content` ADD `vers` VARCHAR( 255 ) NOT … Read more

How to perform a basic PHP Installation

Within this article we will be configuring a basic php installation using Apache.Note : The steps are based upon the CentOS 5 distro. Install Apache / PHP First of all you will need to install Apache and php via yum. yum install httpd php Edit php.ini Within /etc/php.ini ensure the following settings are configured by … Read more

Adding a custom module position to the RocketTheme Afterburner template

In this article we will be adding a custom module position to the RocketTheme Afterburner template. The syntax used here will be specfic to the Afterburner template but you should be able to adjust and use as nessecary within your own template. Add the following code to the following files within /templates/rt_afterburner_j15/ index.php <div id=”nav”><jdoc:include … Read more

How do I remove the Title Filter and Display # from the Category List within Joomla ?

In order to remove the  Title Filter and Display # from the Category list remove the following code from the file \templates\[your-template]\html\com_content\category\default-items.php {codecitation class=”brush:php”} <?php if ($this->params->get(‘filter’) || $this->params->get(‘show_pagination_limit’)) : ?><tr> <td colspan=”5″> <table> <tr> <td align=”left” width=”60%” nowrap=”nowrap”> <input type=”text” name=”filter” value=”” class=”inputbox” onchange=”document.adminForm.submit();” /> </td> <td align=”right” width=”40%” nowrap=”nowrap”> <?php echo ‘   ‘.JText::_(‘Display Num’).’ ‘; … Read more

Serious db problem:Unknown column ‘fbviewtype’ in ‘field list’ SQL=select fbviewtype from jos_comprofiler where user_id=’62’

Issue When using Fireboard and Community Builder. You may find that when you try to access your Fireboard forum from your website (frontend) after logging in you receive the following error : Serious db problem:Unknown column ‘fbviewtype’ in ‘field list’ SQL=select fbviewtype from jos_comprofiler where user_id=’62’ Solution To resolve this goto “Fireboard Forum –> Fireboard … Read more

How do I create a page using just a module in Joomla 1.5.x ?

Scenerio In this scenerio we will require to create a page using only a module. In order to accomplish this we use a built in Joomla Plugin called “Content – Load Module“. This is enabled by installed and enabled by default upon Joomla Installation. Required Steps Below details the required steps for created a page … Read more

Fatal error: Allowed memory size of 8388608 bytes exhausted

You may see the following error when the memory requirements of your PHP script exceeds the default 8MB limit. Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2682912 bytes) in /opt/lampp/htdocs/site/libraries/joomla/filesystem/archive/gzip.php on line 77 To resolve this change the line that reads  ‘memory_limit = 8M‘ to  ‘memory_limit = 16M’  within your … Read more

Want to become a Web Development expert?

Here is our hand-picked selection of the best courses you can find online:
The Complete Web Development Bootcamp course
PHP for Beginners course
Write PHP like a Pro course
Django Practical Guide course
Django Full Stack Developer Bootcamp
Joomla for Beginners course
Professional Websites with Joomla Gantry course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial