• Django version upgrades

    Django 1.10.3 adds important change in settings

    The latest Django update, version 1.10.3 adds an important change to how Django handles the ALLOWED_HOSTS setting in your project. Previously, when running in debug mode (with DEBUG=True setting) Django ignored the ALLOWED_HOSTS setting, accepting any hostname. Since the latest update Django will validate the values in this setting regardless of the DEBUG  setting. For convenience, if ALLOWED_HOSTS is empty and DEBUG=True, the following variations of localhost are allowed [‘localhost’, ‘’, ‘::1’]. This change might present an issue for you if you are running a QA version of your project with the DEBUG setting or if you’re developing using production settings in the ALLOWED_HOSTS setting. Read the changelog for version 1.10.3

  • Django,  Recipes

    Permission checking in Django views

    When using the django.contrib.auth application in your project you have a number of options available for permission checking. In this recipe we will go over a number of possibilities provided by Django and offer a custom pattern you can implement. Simple testing of User objects When using function based views in your Django apps you can use the [crayon-5c6f850de1576479667166-i/]  decorator. This is a function decorator provided by Django that you can apply to a view function. Like the decorator name says, it tests a user object. The callable you pass the decorator should take a User object and return [crayon-5c6f850de157a380956311-i/]  when your test passes. Return [crayon-5c6f850de157b340071077-i/]  from your callable to perform a…