meta-openembedded and poky: subtree updates

Squash of the following due to dependencies among them
and OpenBMC changes:

meta-openembedded: subtree update:d0748372d2..9201611135
meta-openembedded: subtree update:9201611135..17fd382f34
poky: subtree update:9052e5b32a..2e11d97b6c
poky: subtree update:2e11d97b6c..a8544811d7

The change log was too large for the jenkins plugin
to handle therefore it has been removed. Here is
the first and last commit of each subtree:

meta-openembedded:d0748372d2
      cppzmq: bump to version 4.6.0
meta-openembedded:17fd382f34
      mpv: Remove X11 dependency
poky:9052e5b32a
      package_ipk: Remove pointless comment to trigger rebuild
poky:a8544811d7
      pbzip2: Fix license warning

Change-Id: If0fc6c37629642ee207a4ca2f7aa501a2c673cd6
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/poky/bitbake/lib/toaster/bldcollector/urls.py b/poky/bitbake/lib/toaster/bldcollector/urls.py
index 8eb1e34..efd67a8 100644
--- a/poky/bitbake/lib/toaster/bldcollector/urls.py
+++ b/poky/bitbake/lib/toaster/bldcollector/urls.py
@@ -6,7 +6,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.conf.urls import include, url
+from django.conf.urls import url
 
 import bldcollector.views
 
diff --git a/poky/bitbake/lib/toaster/bldcollector/views.py b/poky/bitbake/lib/toaster/bldcollector/views.py
index c708b41..04cd8b3 100644
--- a/poky/bitbake/lib/toaster/bldcollector/views.py
+++ b/poky/bitbake/lib/toaster/bldcollector/views.py
@@ -6,16 +6,8 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.views.decorators.cache import cache_control
-from django.core.urlresolvers import reverse
-from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
+from django.urls import reverse
 from django.http import HttpResponseBadRequest, HttpResponse
-from django.utils import timezone
-from django.utils.html import escape
-from datetime import timedelta
-from django.utils import formats
-from toastergui.templatetags.projecttags import json as jsonfilter
-import json
 import os
 import tempfile
 import subprocess
diff --git a/poky/bitbake/lib/toaster/bldcontrol/admin.py b/poky/bitbake/lib/toaster/bldcontrol/admin.py
index e85c30e..1754bc1 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/admin.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/admin.py
@@ -3,7 +3,6 @@
 #
 
 from django.contrib import admin
-from django.contrib.admin.filters import RelatedFieldListFilter
 from .models import BuildEnvironment
 
 class BuildEnvironmentAdmin(admin.ModelAdmin):
diff --git a/poky/bitbake/lib/toaster/bldcontrol/bbcontroller.py b/poky/bitbake/lib/toaster/bldcontrol/bbcontroller.py
index 301df18..71c288d 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/bbcontroller.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/bbcontroller.py
@@ -8,10 +8,8 @@
 
 import os
 import sys
-import re
-from django.db import transaction
 from django.db.models import Q
-from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake
+from bldcontrol.models import BuildEnvironment, BRLayer, BRBitbake
 
 # load Bitbake components
 path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
diff --git a/poky/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/poky/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
index 39ea736..75674cc 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -7,27 +7,24 @@
 #
 
 import os
-import sys
 import re
 import shutil
 import time
-from django.db import transaction
-from django.db.models import Q
-from bldcontrol.models import BuildEnvironment, BuildRequest, BRLayer, BRVariable, BRTarget, BRBitbake, Build
-from orm.models import CustomImageRecipe, Layer, Layer_Version, Project, ProjectLayer, ToasterSetting
+from bldcontrol.models import BuildEnvironment, BuildRequest, Build
+from orm.models import CustomImageRecipe, Layer, Layer_Version, Project, ToasterSetting
 from orm.models import signal_runbuilds
 import subprocess
 
 from toastermain import settings
 
-from bldcontrol.bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException, BitbakeController
+from bldcontrol.bbcontroller import BuildEnvironmentController, ShellCmdException, BuildSetupException
 
 import logging
 logger = logging.getLogger("toaster")
 
 install_dir = os.environ.get('TOASTER_DIR')
 
-from pprint import pprint, pformat
+from pprint import pformat
 
 class LocalhostBEController(BuildEnvironmentController):
     """ Implementation of the BuildEnvironmentController for the localhost;
diff --git a/poky/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/poky/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index fe2c4dc..20f9dce 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -2,11 +2,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.management.base import BaseCommand, CommandError
-from django.db import transaction
+from django.core.management.base import BaseCommand
 
 from django.core.management import call_command
-from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException
 from bldcontrol.models import BuildRequest, BuildEnvironment, BRError
 from orm.models import ToasterSetting, Build, Layer
 
@@ -80,7 +78,7 @@
                         template_conf = os.environ.get("TEMPLATECONF", "")
                         custom_xml_only = os.environ.get("CUSTOM_XML_ONLY")
 
-                        if ToasterSetting.objects.filter(name='CUSTOM_XML_ONLY').count() > 0 or (not custom_xml_only == None):
+                        if ToasterSetting.objects.filter(name='CUSTOM_XML_ONLY').count() > 0 or custom_xml_only is not None:
                             # only use the custom settings
                             pass
                         elif "poky" in template_conf:
diff --git a/poky/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/poky/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 50ec409..19f659e 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -168,17 +168,17 @@
         try:
             self.cleanup()
         except Exception as e:
-            logger.warn("runbuilds: cleanup exception %s" % str(e))
+            logger.warning("runbuilds: cleanup exception %s" % str(e))
 
         try:
             self.archive()
         except Exception as e:
-            logger.warn("runbuilds: archive exception %s" % str(e))
+            logger.warning("runbuilds: archive exception %s" % str(e))
 
         try:
             self.schedule()
         except Exception as e:
-            logger.warn("runbuilds: schedule exception %s" % str(e))
+            logger.warning("runbuilds: schedule exception %s" % str(e))
 
     def handle(self, **options):
         pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."),
diff --git a/poky/bitbake/lib/toaster/bldcontrol/migrations/0001_initial.py b/poky/bitbake/lib/toaster/bldcontrol/migrations/0001_initial.py
index 67db378..7ee19f4 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/migrations/0001_initial.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/migrations/0001_initial.py
@@ -37,7 +37,7 @@
                 ('giturl', models.CharField(max_length=254)),
                 ('commit', models.CharField(max_length=254)),
                 ('dirpath', models.CharField(max_length=254)),
-                ('layer_version', models.ForeignKey(to='orm.Layer_Version', null=True)),
+                ('layer_version', models.ForeignKey(to='orm.Layer_Version', null=True, on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -80,34 +80,34 @@
                 ('state', models.IntegerField(default=0, choices=[(0, b'created'), (1, b'queued'), (2, b'in progress'), (3, b'completed'), (4, b'failed'), (5, b'deleted'), (6, b'archive')])),
                 ('created', models.DateTimeField(auto_now_add=True)),
                 ('updated', models.DateTimeField(auto_now=True)),
-                ('build', models.OneToOneField(null=True, to='orm.Build')),
-                ('environment', models.ForeignKey(to='bldcontrol.BuildEnvironment', null=True)),
-                ('project', models.ForeignKey(to='orm.Project')),
+                ('build', models.OneToOneField(null=True, to='orm.Build', on_delete=models.CASCADE)),
+                ('environment', models.ForeignKey(to='bldcontrol.BuildEnvironment', null=True, on_delete=models.CASCADE)),
+                ('project', models.ForeignKey(to='orm.Project', on_delete=models.CASCADE)),
             ],
         ),
         migrations.AddField(
             model_name='brvariable',
             name='req',
-            field=models.ForeignKey(to='bldcontrol.BuildRequest'),
+            field=models.ForeignKey(to='bldcontrol.BuildRequest', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='brtarget',
             name='req',
-            field=models.ForeignKey(to='bldcontrol.BuildRequest'),
+            field=models.ForeignKey(to='bldcontrol.BuildRequest', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='brlayer',
             name='req',
-            field=models.ForeignKey(to='bldcontrol.BuildRequest'),
+            field=models.ForeignKey(to='bldcontrol.BuildRequest', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='brerror',
             name='req',
-            field=models.ForeignKey(to='bldcontrol.BuildRequest'),
+            field=models.ForeignKey(to='bldcontrol.BuildRequest', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='brbitbake',
             name='req',
-            field=models.OneToOneField(to='bldcontrol.BuildRequest'),
+            field=models.OneToOneField(to='bldcontrol.BuildRequest', on_delete=models.CASCADE),
         ),
     ]
diff --git a/poky/bitbake/lib/toaster/bldcontrol/models.py b/poky/bitbake/lib/toaster/bldcontrol/models.py
index bcffcf5..c2f302d 100644
--- a/poky/bitbake/lib/toaster/bldcontrol/models.py
+++ b/poky/bitbake/lib/toaster/bldcontrol/models.py
@@ -4,9 +4,8 @@
 
 from __future__ import unicode_literals
 from django.db import models
-from django.core.validators import MaxValueValidator, MinValueValidator
 from django.utils.encoding import force_text
-from orm.models import Project, ProjectLayer, ProjectVariable, ProjectTarget, Build, Layer_Version
+from orm.models import Project, Build, Layer_Version
 
 import logging
 logger = logging.getLogger("toaster")
@@ -86,9 +85,9 @@
 
     search_allowed_fields = ("brtarget__target", "build__project__name")
 
-    project     = models.ForeignKey(Project)
-    build       = models.OneToOneField(Build, null = True)     # TODO: toasterui should set this when Build is created
-    environment = models.ForeignKey(BuildEnvironment, null = True)
+    project     = models.ForeignKey(Project, on_delete=models.CASCADE)
+    build       = models.OneToOneField(Build, on_delete=models.CASCADE, null = True)     # TODO: toasterui should set this when Build is created
+    environment = models.ForeignKey(BuildEnvironment, on_delete=models.CASCADE, null = True)
     state       = models.IntegerField(choices = REQUEST_STATE, default = REQ_CREATED)
     created     = models.DateTimeField(auto_now_add = True)
     updated     = models.DateTimeField(auto_now = True)
@@ -132,32 +131,32 @@
 
 
 class BRLayer(models.Model):
-    req = models.ForeignKey(BuildRequest)
+    req = models.ForeignKey(BuildRequest, on_delete=models.CASCADE)
     name = models.CharField(max_length=100)
     giturl = models.CharField(max_length=254, null=True)
     local_source_dir = models.CharField(max_length=254, null=True)
     commit = models.CharField(max_length=254, null=True)
     dirpath = models.CharField(max_length=254, null=True)
-    layer_version = models.ForeignKey(Layer_Version, null=True)
+    layer_version = models.ForeignKey(Layer_Version, on_delete=models.CASCADE, null=True)
 
 class BRBitbake(models.Model):
-    req         = models.OneToOneField(BuildRequest)    # only one bitbake for a request
+    req         = models.OneToOneField(BuildRequest, on_delete=models.CASCADE)    # only one bitbake for a request
     giturl      = models.CharField(max_length =254)
     commit      = models.CharField(max_length = 254)
     dirpath     = models.CharField(max_length = 254)
 
 class BRVariable(models.Model):
-    req         = models.ForeignKey(BuildRequest)
+    req         = models.ForeignKey(BuildRequest, on_delete=models.CASCADE)
     name        = models.CharField(max_length=100)
     value       = models.TextField(blank = True)
 
 class BRTarget(models.Model):
-    req         = models.ForeignKey(BuildRequest)
+    req         = models.ForeignKey(BuildRequest, on_delete=models.CASCADE)
     target      = models.CharField(max_length=100)
     task        = models.CharField(max_length=100, null=True)
 
 class BRError(models.Model):
-    req         = models.ForeignKey(BuildRequest)
+    req         = models.ForeignKey(BuildRequest, on_delete=models.CASCADE)
     errtype     = models.CharField(max_length=100)
     errmsg      = models.TextField()
     traceback   = models.TextField()
diff --git a/poky/bitbake/lib/toaster/orm/fixtures/oe-core.xml b/poky/bitbake/lib/toaster/orm/fixtures/oe-core.xml
index a723f5a..fd93f4d 100644
--- a/poky/bitbake/lib/toaster/orm/fixtures/oe-core.xml
+++ b/poky/bitbake/lib/toaster/orm/fixtures/oe-core.xml
@@ -8,9 +8,9 @@
 
   <!-- Bitbake versions which correspond to the metadata release -->
   <object model="orm.bitbakeversion" pk="1">
-    <field type="CharField" name="name">warrior</field>
+    <field type="CharField" name="name">dunfell</field>
     <field type="CharField" name="giturl">git://git.openembedded.org/bitbake</field>
-    <field type="CharField" name="branch">1.42</field>
+    <field type="CharField" name="branch">1.46</field>
   </object>
   <object model="orm.bitbakeversion" pk="2">
     <field type="CharField" name="name">HEAD</field>
@@ -30,11 +30,11 @@
 
   <!-- Releases available -->
   <object model="orm.release" pk="1">
-    <field type="CharField" name="name">warrior</field>
-    <field type="CharField" name="description">Openembedded Warrior</field>
+    <field type="CharField" name="name">dunfell</field>
+    <field type="CharField" name="description">Openembedded Dunfell</field>
     <field rel="ManyToOneRel" to="orm.bitbakeversion" name="bitbake_version">1</field>
-    <field type="CharField" name="branch_name">warrior</field>
-    <field type="TextField" name="helptext">Toaster will run your builds using the tip of the &lt;a href=\"http://cgit.openembedded.org/openembedded-core/log/?h=warrior\"&gt;OpenEmbedded Warrior&lt;/a&gt; branch.</field>
+    <field type="CharField" name="branch_name">dunfell</field>
+    <field type="TextField" name="helptext">Toaster will run your builds using the tip of the &lt;a href=\"http://cgit.openembedded.org/openembedded-core/log/?h=dunfell\"&gt;OpenEmbedded Dunfell&lt;/a&gt; branch.</field>
   </object>
   <object model="orm.release" pk="2">
     <field type="CharField" name="name">local</field>
diff --git a/poky/bitbake/lib/toaster/orm/fixtures/poky.xml b/poky/bitbake/lib/toaster/orm/fixtures/poky.xml
index 7992383..902bc88 100644
--- a/poky/bitbake/lib/toaster/orm/fixtures/poky.xml
+++ b/poky/bitbake/lib/toaster/orm/fixtures/poky.xml
@@ -8,9 +8,9 @@
 
   <!-- Bitbake versions which correspond to the metadata release -->
   <object model="orm.bitbakeversion" pk="1">
-    <field type="CharField" name="name">warrior</field>
+    <field type="CharField" name="name">dunfell</field>
     <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field>
-    <field type="CharField" name="branch">warrior</field>
+    <field type="CharField" name="branch">dunfell</field>
     <field type="CharField" name="dirpath">bitbake</field>
   </object>
   <object model="orm.bitbakeversion" pk="2">
@@ -35,11 +35,11 @@
 
   <!-- Releases available -->
   <object model="orm.release" pk="1">
-    <field type="CharField" name="name">warrior</field>
-    <field type="CharField" name="description">Yocto Project 2.7 "Warrior"</field>
+    <field type="CharField" name="name">dunfell</field>
+    <field type="CharField" name="description">Yocto Project 3.1 "Dunfell"</field>
     <field rel="ManyToOneRel" to="orm.bitbakeversion" name="bitbake_version">1</field>
-    <field type="CharField" name="branch_name">warrior</field>
-    <field type="TextField" name="helptext">Toaster will run your builds using the tip of the &lt;a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=warrior"&gt;Yocto Project Warrior branch&lt;/a&gt;.</field>
+    <field type="CharField" name="branch_name">dunfell</field>
+    <field type="TextField" name="helptext">Toaster will run your builds using the tip of the &lt;a href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=dunfell"&gt;Yocto Project Dunfell branch&lt;/a&gt;.</field>
   </object>
   <object model="orm.release" pk="2">
     <field type="CharField" name="name">local</field>
@@ -130,7 +130,7 @@
     <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
     <field type="IntegerField" name="layer_source">0</field>
     <field rel="ManyToOneRel" to="orm.release" name="release">1</field>
-    <field type="CharField" name="branch">warrior</field>
+    <field type="CharField" name="branch">dunfell</field>
     <field type="CharField" name="dirpath">meta</field>
   </object>
   <object model="orm.layer_version" pk="2">
@@ -168,7 +168,7 @@
     <field rel="ManyToOneRel" to="orm.layer" name="layer">2</field>
     <field type="IntegerField" name="layer_source">0</field>
     <field rel="ManyToOneRel" to="orm.release" name="release">1</field>
-    <field type="CharField" name="branch">warrior</field>
+    <field type="CharField" name="branch">dunfell</field>
     <field type="CharField" name="dirpath">meta-poky</field>
   </object>
   <object model="orm.layer_version" pk="6">
@@ -206,7 +206,7 @@
     <field rel="ManyToOneRel" to="orm.layer" name="layer">3</field>
     <field type="IntegerField" name="layer_source">0</field>
     <field rel="ManyToOneRel" to="orm.release" name="release">1</field>
-    <field type="CharField" name="branch">warrior</field>
+    <field type="CharField" name="branch">dunfell</field>
     <field type="CharField" name="dirpath">meta-yocto-bsp</field>
   </object>
   <object model="orm.layer_version" pk="10">
diff --git a/poky/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/poky/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index 5b5abbb..a4dbcaa 100644
--- a/poky/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/poky/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -8,7 +8,7 @@
 
 from django.core.management.base import BaseCommand
 
-from orm.models import LayerSource, Layer, Release, Layer_Version
+from orm.models import Layer, Release, Layer_Version
 from orm.models import LayerVersionDependency, Machine, Recipe
 from orm.models import Distro
 from orm.models import ToasterSetting
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0001_initial.py b/poky/bitbake/lib/toaster/orm/migrations/0001_initial.py
index 760462f..a8ac23b 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0001_initial.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0001_initial.py
@@ -54,7 +54,7 @@
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('file_name', models.FilePathField()),
                 ('file_size', models.IntegerField()),
-                ('build', models.ForeignKey(to='orm.Build')),
+                ('build', models.ForeignKey(to='orm.Build', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -64,7 +64,7 @@
                 ('area', models.IntegerField(choices=[(0, b'variable')])),
                 ('key', models.CharField(max_length=100)),
                 ('text', models.TextField()),
-                ('build', models.ForeignKey(related_name='helptext_build', to='orm.Build')),
+                ('build', models.ForeignKey(related_name='helptext_build', to='orm.Build', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -94,8 +94,8 @@
                 ('dirpath', models.CharField(default=None, max_length=255, null=True)),
                 ('priority', models.IntegerField(default=0)),
                 ('local_path', models.FilePathField(default=b'/', max_length=1024)),
-                ('build', models.ForeignKey(related_name='layer_version_build', default=None, to='orm.Build', null=True)),
-                ('layer', models.ForeignKey(related_name='layer_version_layer', to='orm.Layer')),
+                ('build', models.ForeignKey(related_name='layer_version_build', default=None, to='orm.Build', null=True, on_delete=models.CASCADE)),
+                ('layer', models.ForeignKey(related_name='layer_version_layer', to='orm.Layer', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -112,9 +112,9 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('up_id', models.IntegerField(default=None, null=True)),
-                ('depends_on', models.ForeignKey(related_name='dependees', to='orm.Layer_Version')),
-                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True)),
-                ('layer_version', models.ForeignKey(related_name='dependencies', to='orm.Layer_Version')),
+                ('depends_on', models.ForeignKey(related_name='dependees', to='orm.Layer_Version', on_delete=models.CASCADE)),
+                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True, on_delete=models.CASCADE)),
+                ('layer_version', models.ForeignKey(related_name='dependencies', to='orm.Layer_Version', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -125,7 +125,7 @@
                 ('message', models.TextField(null=True, blank=True)),
                 ('pathname', models.FilePathField(max_length=255, blank=True)),
                 ('lineno', models.IntegerField(null=True)),
-                ('build', models.ForeignKey(to='orm.Build')),
+                ('build', models.ForeignKey(to='orm.Build', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -136,8 +136,8 @@
                 ('up_date', models.DateTimeField(default=None, null=True)),
                 ('name', models.CharField(max_length=255)),
                 ('description', models.CharField(max_length=255)),
-                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True)),
-                ('layer_version', models.ForeignKey(to='orm.Layer_Version')),
+                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True, on_delete=models.CASCADE)),
+                ('layer_version', models.ForeignKey(to='orm.Layer_Version', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -154,7 +154,7 @@
                 ('installed_size', models.IntegerField(default=0)),
                 ('section', models.CharField(max_length=80, blank=True)),
                 ('license', models.CharField(max_length=80, blank=True)),
-                ('build', models.ForeignKey(to='orm.Build', null=True)),
+                ('build', models.ForeignKey(to='orm.Build', null=True, on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -162,8 +162,8 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('dep_type', models.IntegerField(choices=[(0, b'depends'), (1, b'depends'), (3, b'recommends'), (2, b'recommends'), (4, b'suggests'), (5, b'provides'), (6, b'replaces'), (7, b'conflicts')])),
-                ('depends_on', models.ForeignKey(related_name='package_dependencies_target', to='orm.Package')),
-                ('package', models.ForeignKey(related_name='package_dependencies_source', to='orm.Package')),
+                ('depends_on', models.ForeignKey(related_name='package_dependencies_target', to='orm.Package', on_delete=models.CASCADE)),
+                ('package', models.ForeignKey(related_name='package_dependencies_source', to='orm.Package', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -172,7 +172,7 @@
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('path', models.FilePathField(max_length=255, blank=True)),
                 ('size', models.IntegerField()),
-                ('package', models.ForeignKey(related_name='buildfilelist_package', to='orm.Package')),
+                ('package', models.ForeignKey(related_name='buildfilelist_package', to='orm.Package', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -185,7 +185,7 @@
                 ('updated', models.DateTimeField(auto_now=True)),
                 ('user_id', models.IntegerField(null=True)),
                 ('is_default', models.BooleanField(default=False)),
-                ('bitbake_version', models.ForeignKey(to='orm.BitbakeVersion', null=True)),
+                ('bitbake_version', models.ForeignKey(to='orm.BitbakeVersion', null=True, on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -193,8 +193,8 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('optional', models.BooleanField(default=True)),
-                ('layercommit', models.ForeignKey(to='orm.Layer_Version', null=True)),
-                ('project', models.ForeignKey(to='orm.Project')),
+                ('layercommit', models.ForeignKey(to='orm.Layer_Version', null=True, on_delete=models.CASCADE)),
+                ('project', models.ForeignKey(to='orm.Project', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -203,7 +203,7 @@
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('target', models.CharField(max_length=100)),
                 ('task', models.CharField(max_length=100, null=True)),
-                ('project', models.ForeignKey(to='orm.Project')),
+                ('project', models.ForeignKey(to='orm.Project', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -212,7 +212,7 @@
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('name', models.CharField(max_length=100)),
                 ('value', models.TextField(blank=True)),
-                ('project', models.ForeignKey(to='orm.Project')),
+                ('project', models.ForeignKey(to='orm.Project', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -232,8 +232,8 @@
                 ('file_path', models.FilePathField(max_length=255)),
                 ('pathflags', models.CharField(max_length=200, blank=True)),
                 ('is_image', models.BooleanField(default=False)),
-                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True)),
-                ('layer_version', models.ForeignKey(related_name='recipe_layer_version', to='orm.Layer_Version')),
+                ('layer_source', models.ForeignKey(default=None, to='orm.LayerSource', null=True, on_delete=models.CASCADE)),
+                ('layer_version', models.ForeignKey(related_name='recipe_layer_version', to='orm.Layer_Version', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -241,8 +241,8 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('dep_type', models.IntegerField(choices=[(0, b'depends'), (1, b'rdepends')])),
-                ('depends_on', models.ForeignKey(related_name='r_dependencies_depends', to='orm.Recipe')),
-                ('recipe', models.ForeignKey(related_name='r_dependencies_recipe', to='orm.Recipe')),
+                ('depends_on', models.ForeignKey(related_name='r_dependencies_depends', to='orm.Recipe', on_delete=models.CASCADE)),
+                ('recipe', models.ForeignKey(related_name='r_dependencies_recipe', to='orm.Recipe', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -253,7 +253,7 @@
                 ('description', models.CharField(max_length=255)),
                 ('branch_name', models.CharField(default=b'', max_length=50)),
                 ('helptext', models.TextField(null=True)),
-                ('bitbake_version', models.ForeignKey(to='orm.BitbakeVersion')),
+                ('bitbake_version', models.ForeignKey(to='orm.BitbakeVersion', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -261,7 +261,7 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('layer_name', models.CharField(default=b'', max_length=100)),
-                ('release', models.ForeignKey(to='orm.Release')),
+                ('release', models.ForeignKey(to='orm.Release', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -269,8 +269,8 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('priority', models.IntegerField(default=0)),
-                ('layer_source', models.ForeignKey(to='orm.LayerSource')),
-                ('release', models.ForeignKey(to='orm.Release')),
+                ('layer_source', models.ForeignKey(to='orm.LayerSource', on_delete=models.CASCADE)),
+                ('release', models.ForeignKey(to='orm.Release', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -282,7 +282,7 @@
                 ('is_image', models.BooleanField(default=False)),
                 ('image_size', models.IntegerField(default=0)),
                 ('license_manifest_path', models.CharField(max_length=500, null=True)),
-                ('build', models.ForeignKey(to='orm.Build')),
+                ('build', models.ForeignKey(to='orm.Build', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -295,9 +295,9 @@
                 ('permission', models.CharField(max_length=16)),
                 ('owner', models.CharField(max_length=128)),
                 ('group', models.CharField(max_length=128)),
-                ('directory', models.ForeignKey(related_name='directory_set', to='orm.Target_File', null=True)),
-                ('sym_target', models.ForeignKey(related_name='symlink_set', to='orm.Target_File', null=True)),
-                ('target', models.ForeignKey(to='orm.Target')),
+                ('directory', models.ForeignKey(related_name='directory_set', to='orm.Target_File', null=True, on_delete=models.CASCADE)),
+                ('sym_target', models.ForeignKey(related_name='symlink_set', to='orm.Target_File', null=True, on_delete=models.CASCADE)),
+                ('target', models.ForeignKey(to='orm.Target', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -306,15 +306,15 @@
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('file_name', models.FilePathField(max_length=254)),
                 ('file_size', models.IntegerField()),
-                ('target', models.ForeignKey(to='orm.Target')),
+                ('target', models.ForeignKey(to='orm.Target', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
             name='Target_Installed_Package',
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('package', models.ForeignKey(related_name='buildtargetlist_package', to='orm.Package')),
-                ('target', models.ForeignKey(to='orm.Target')),
+                ('package', models.ForeignKey(related_name='buildtargetlist_package', to='orm.Package', on_delete=models.CASCADE)),
+                ('target', models.ForeignKey(to='orm.Target', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -337,8 +337,8 @@
                 ('sstate_result', models.IntegerField(default=0, choices=[(0, b'Not Applicable'), (1, b'File not in cache'), (2, b'Failed'), (3, b'Succeeded')])),
                 ('message', models.CharField(max_length=240)),
                 ('logfile', models.FilePathField(max_length=255, blank=True)),
-                ('build', models.ForeignKey(related_name='task_build', to='orm.Build')),
-                ('recipe', models.ForeignKey(related_name='tasks', to='orm.Recipe')),
+                ('build', models.ForeignKey(related_name='task_build', to='orm.Build', on_delete=models.CASCADE)),
+                ('recipe', models.ForeignKey(related_name='tasks', to='orm.Recipe', on_delete=models.CASCADE)),
             ],
             options={
                 'ordering': ('order', 'recipe'),
@@ -348,8 +348,8 @@
             name='Task_Dependency',
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
-                ('depends_on', models.ForeignKey(related_name='task_dependencies_depends', to='orm.Task')),
-                ('task', models.ForeignKey(related_name='task_dependencies_task', to='orm.Task')),
+                ('depends_on', models.ForeignKey(related_name='task_dependencies_depends', to='orm.Task', on_delete=models.CASCADE)),
+                ('task', models.ForeignKey(related_name='task_dependencies_task', to='orm.Task', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -370,7 +370,7 @@
                 ('changed', models.BooleanField(default=False)),
                 ('human_readable_name', models.CharField(max_length=200)),
                 ('description', models.TextField(blank=True)),
-                ('build', models.ForeignKey(related_name='variable_build', to='orm.Build')),
+                ('build', models.ForeignKey(related_name='variable_build', to='orm.Build', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -381,28 +381,28 @@
                 ('file_name', models.FilePathField(max_length=255)),
                 ('line_number', models.IntegerField(null=True)),
                 ('operation', models.CharField(max_length=64)),
-                ('variable', models.ForeignKey(related_name='vhistory', to='orm.Variable')),
+                ('variable', models.ForeignKey(related_name='vhistory', to='orm.Variable', on_delete=models.CASCADE)),
             ],
         ),
         migrations.AddField(
             model_name='project',
             name='release',
-            field=models.ForeignKey(to='orm.Release', null=True),
+            field=models.ForeignKey(to='orm.Release', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='package_dependency',
             name='target',
-            field=models.ForeignKey(to='orm.Target', null=True),
+            field=models.ForeignKey(to='orm.Target', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='package',
             name='recipe',
-            field=models.ForeignKey(to='orm.Recipe', null=True),
+            field=models.ForeignKey(to='orm.Recipe', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='logmessage',
             name='task',
-            field=models.ForeignKey(blank=True, to='orm.Task', null=True),
+            field=models.ForeignKey(blank=True, to='orm.Task', null=True, on_delete=models.CASCADE),
         ),
         migrations.AlterUniqueTogether(
             name='layersource',
@@ -411,32 +411,32 @@
         migrations.AddField(
             model_name='layer_version',
             name='layer_source',
-            field=models.ForeignKey(default=None, to='orm.LayerSource', null=True),
+            field=models.ForeignKey(default=None, to='orm.LayerSource', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='layer_version',
             name='project',
-            field=models.ForeignKey(default=None, to='orm.Project', null=True),
+            field=models.ForeignKey(default=None, to='orm.Project', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='layer_version',
             name='up_branch',
-            field=models.ForeignKey(default=None, to='orm.Branch', null=True),
+            field=models.ForeignKey(default=None, to='orm.Branch', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='layer',
             name='layer_source',
-            field=models.ForeignKey(default=None, to='orm.LayerSource', null=True),
+            field=models.ForeignKey(default=None, to='orm.LayerSource', null=True, on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='build',
             name='project',
-            field=models.ForeignKey(to='orm.Project'),
+            field=models.ForeignKey(to='orm.Project', on_delete=models.CASCADE),
         ),
         migrations.AddField(
             model_name='branch',
             name='layer_source',
-            field=models.ForeignKey(default=True, to='orm.LayerSource', null=True),
+            field=models.ForeignKey(default=True, to='orm.LayerSource', null=True, on_delete=models.CASCADE),
         ),
         migrations.CreateModel(
             name='ImportedLayerSource',
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py b/poky/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
index 9cec82e..09c2bff 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0002_customimagerecipe.py
@@ -14,10 +14,10 @@
         migrations.CreateModel(
             name='CustomImageRecipe',
             fields=[
-                ('recipe_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Recipe')),
+                ('recipe_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Recipe', on_delete=models.CASCADE)),
                 ('last_updated', models.DateTimeField(default=None, null=True)),
-                ('base_recipe', models.ForeignKey(related_name='based_on_recipe', to='orm.Recipe')),
-                ('project', models.ForeignKey(to='orm.Project')),
+                ('base_recipe', models.ForeignKey(related_name='based_on_recipe', to='orm.Recipe', on_delete=models.CASCADE)),
+                ('project', models.ForeignKey(to='orm.Project', on_delete=models.CASCADE)),
             ],
             bases=('orm.recipe',),
         ),
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py b/poky/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
index b027f66..8cb81d7 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0003_customimagepackage.py
@@ -14,7 +14,7 @@
         migrations.CreateModel(
             name='CustomImagePackage',
             fields=[
-                ('package_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Package')),
+                ('package_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='orm.Package', on_delete=models.CASCADE)),
                 ('recipe_appends', models.ManyToManyField(related_name='appends_set', to='orm.CustomImageRecipe')),
                 ('recipe_excludes', models.ManyToManyField(related_name='excludes_set', to='orm.CustomImageRecipe')),
                 ('recipe_includes', models.ManyToManyField(related_name='includes_set', to='orm.CustomImageRecipe')),
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0004_provides.py b/poky/bitbake/lib/toaster/orm/migrations/0004_provides.py
index dfde2d1..8449604 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0004_provides.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0004_provides.py
@@ -16,12 +16,12 @@
             fields=[
                 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                 ('name', models.CharField(max_length=100)),
-                ('recipe', models.ForeignKey(to='orm.Recipe')),
+                ('recipe', models.ForeignKey(to='orm.Recipe', on_delete=models.CASCADE)),
             ],
         ),
         migrations.AddField(
             model_name='recipe_dependency',
             name='via',
-            field=models.ForeignKey(null=True, default=None, to='orm.Provides'),
+            field=models.ForeignKey(null=True, default=None, to='orm.Provides', on_delete=models.CASCADE),
         ),
     ]
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0008_refactor_artifact_models.py b/poky/bitbake/lib/toaster/orm/migrations/0008_refactor_artifact_models.py
index 3367582..41a547a 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0008_refactor_artifact_models.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0008_refactor_artifact_models.py
@@ -17,7 +17,7 @@
                 ('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)),
                 ('file_name', models.FilePathField()),
                 ('file_size', models.IntegerField()),
-                ('target', models.ForeignKey(to='orm.Target')),
+                ('target', models.ForeignKey(to='orm.Target', on_delete=models.CASCADE)),
             ],
         ),
         migrations.CreateModel(
@@ -26,7 +26,7 @@
                 ('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)),
                 ('file_name', models.FilePathField()),
                 ('file_size', models.IntegerField()),
-                ('target', models.ForeignKey(to='orm.Target')),
+                ('target', models.ForeignKey(to='orm.Target', on_delete=models.CASCADE)),
             ],
         ),
         migrations.RemoveField(
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py b/poky/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py
index 7550696..3f3a2e1 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import migrations, models
+from django.db import migrations
 
 
 class Migration(migrations.Migration):
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py b/poky/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py
index 0e6bb83..4b96bf0 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py
@@ -46,7 +46,7 @@
         migrations.AddField(
             model_name='layer_version',
             name='release',
-            field=models.ForeignKey(to='orm.Release', default=None, null=True),
+            field=models.ForeignKey(to='orm.Release', default=None, null=True, on_delete=models.CASCADE),
         ),
         migrations.RunPython(branch_to_release,
                              reverse_code=migrations.RunPython.noop),
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py b/poky/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py
index d3c5901..731c0de 100644
--- a/poky/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py
+++ b/poky/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py
@@ -18,7 +18,7 @@
                 ('up_date', models.DateTimeField(default=None, null=True)),
                 ('name', models.CharField(max_length=255)),
                 ('description', models.CharField(max_length=255)),
-                ('layer_version', models.ForeignKey(to='orm.Layer_Version')),
+                ('layer_version', models.ForeignKey(to='orm.Layer_Version', on_delete=models.CASCADE)),
             ],
         ),
     ]
diff --git a/poky/bitbake/lib/toaster/orm/migrations/0019_django_2_2.py b/poky/bitbake/lib/toaster/orm/migrations/0019_django_2_2.py
new file mode 100644
index 0000000..666aef1
--- /dev/null
+++ b/poky/bitbake/lib/toaster/orm/migrations/0019_django_2_2.py
@@ -0,0 +1,23 @@
+# Generated by Django 2.2.7 on 2019-11-19 03:38
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('orm', '0018_project_specific'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='distro',
+            name='up_id',
+        ),
+        migrations.AlterField(
+            model_name='build',
+            name='recipes_parsed',
+            field=models.IntegerField(default=1),
+        ),
+    ]
diff --git a/poky/bitbake/lib/toaster/orm/models.py b/poky/bitbake/lib/toaster/orm/models.py
index bb6b5de..7f7e922 100644
--- a/poky/bitbake/lib/toaster/orm/models.py
+++ b/poky/bitbake/lib/toaster/orm/models.py
@@ -13,7 +13,7 @@
 from django.utils import timezone
 from django.utils.encoding import force_bytes
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 
 from django.core import validators
 from django.conf import settings
@@ -178,8 +178,8 @@
                              'release__branch_name']
     name = models.CharField(max_length=100)
     short_description = models.CharField(max_length=50, blank=True)
-    bitbake_version = models.ForeignKey('BitbakeVersion', null=True)
-    release = models.ForeignKey("Release", null=True)
+    bitbake_version = models.ForeignKey('BitbakeVersion', on_delete=models.CASCADE, null=True)
+    release = models.ForeignKey("Release", on_delete=models.CASCADE, null=True)
     created = models.DateTimeField(auto_now_add=True)
     updated = models.DateTimeField(auto_now=True)
     # This is a horrible hack; since Toaster has no "User" model available when
@@ -469,7 +469,7 @@
 
     search_allowed_fields = ['machine', 'cooker_log_path', "target__target", "target__target_image_file__file_name"]
 
-    project = models.ForeignKey(Project)            # must have a project
+    project = models.ForeignKey(Project, on_delete=models.CASCADE)            # must have a project
     machine = models.CharField(max_length=100)
     distro = models.CharField(max_length=100)
     distro_version = models.CharField(max_length=100)
@@ -777,13 +777,13 @@
         return "%d %s %s" % (self.id, self.project, ",".join([t.target for t in self.target_set.all()]))
 
 class ProjectTarget(models.Model):
-    project = models.ForeignKey(Project)
+    project = models.ForeignKey(Project, on_delete=models.CASCADE)
     target = models.CharField(max_length=100)
     task = models.CharField(max_length=100, null=True)
 
 class Target(models.Model):
     search_allowed_fields = ['target', 'file_name']
-    build = models.ForeignKey(Build)
+    build = models.ForeignKey(Build, on_delete=models.CASCADE)
     target = models.CharField(max_length=100)
     task = models.CharField(max_length=100, null=True)
     is_image = models.BooleanField(default = False)
@@ -944,7 +944,7 @@
 
 # kernel artifacts for a target: bzImage and modules*
 class TargetKernelFile(models.Model):
-    target = models.ForeignKey(Target)
+    target = models.ForeignKey(Target, on_delete=models.CASCADE)
     file_name = models.FilePathField()
     file_size = models.IntegerField()
 
@@ -954,7 +954,7 @@
 
 # SDK artifacts for a target: sh and manifest files
 class TargetSDKFile(models.Model):
-    target = models.ForeignKey(Target)
+    target = models.ForeignKey(Target, on_delete=models.CASCADE)
     file_name = models.FilePathField()
     file_size = models.IntegerField()
 
@@ -973,7 +973,7 @@
         'ubifs', 'wic', 'wic.bz2', 'wic.gz', 'wic.lzma'
     }
 
-    target = models.ForeignKey(Target)
+    target = models.ForeignKey(Target, on_delete=models.CASCADE)
     file_name = models.FilePathField(max_length=254)
     file_size = models.IntegerField()
 
@@ -1007,15 +1007,15 @@
         ( ITYPE_BLOCK ,'block'),
         )
 
-    target = models.ForeignKey(Target)
+    target = models.ForeignKey(Target, on_delete=models.CASCADE)
     path = models.FilePathField()
     size = models.IntegerField()
     inodetype = models.IntegerField(choices = ITYPES)
     permission = models.CharField(max_length=16)
     owner = models.CharField(max_length=128)
     group = models.CharField(max_length=128)
-    directory = models.ForeignKey('Target_File', related_name="directory_set", null=True)
-    sym_target = models.ForeignKey('Target_File', related_name="symlink_set", null=True)
+    directory = models.ForeignKey('Target_File', on_delete=models.CASCADE, related_name="directory_set", null=True)
+    sym_target = models.ForeignKey('Target_File', on_delete=models.CASCADE, related_name="symlink_set", null=True)
 
 
 class Task(models.Model):
@@ -1102,13 +1102,13 @@
     def get_description(self):
         return self._helptext
 
-    build = models.ForeignKey(Build, related_name='task_build')
+    build = models.ForeignKey(Build, on_delete=models.CASCADE, related_name='task_build')
     order = models.IntegerField(null=True)
     task_executed = models.BooleanField(default=False) # True means Executed, False means Not/Executed
     outcome = models.IntegerField(choices=TASK_OUTCOME, default=OUTCOME_NA)
     sstate_checksum = models.CharField(max_length=100, blank=True)
     path_to_sstate_obj = models.FilePathField(max_length=500, blank=True)
-    recipe = models.ForeignKey('Recipe', related_name='tasks')
+    recipe = models.ForeignKey('Recipe', on_delete=models.CASCADE, related_name='tasks')
     task_name = models.CharField(max_length=100)
     source_url = models.FilePathField(max_length=255, blank=True)
     work_directory = models.FilePathField(max_length=255, blank=True)
@@ -1147,13 +1147,13 @@
 
 
 class Task_Dependency(models.Model):
-    task = models.ForeignKey(Task, related_name='task_dependencies_task')
-    depends_on = models.ForeignKey(Task, related_name='task_dependencies_depends')
+    task = models.ForeignKey(Task, on_delete=models.CASCADE, related_name='task_dependencies_task')
+    depends_on = models.ForeignKey(Task, on_delete=models.CASCADE, related_name='task_dependencies_depends')
 
 class Package(models.Model):
     search_allowed_fields = ['name', 'version', 'revision', 'recipe__name', 'recipe__version', 'recipe__license', 'recipe__layer_version__layer__name', 'recipe__layer_version__branch', 'recipe__layer_version__commit', 'recipe__layer_version__local_path', 'installed_name']
-    build = models.ForeignKey('Build', null=True)
-    recipe = models.ForeignKey('Recipe', null=True)
+    build = models.ForeignKey('Build', on_delete=models.CASCADE, null=True)
+    recipe = models.ForeignKey('Recipe', on_delete=models.CASCADE, null=True)
     name = models.CharField(max_length=100)
     installed_name = models.CharField(max_length=100, default='')
     version = models.CharField(max_length=100, blank=True)
@@ -1289,19 +1289,19 @@
         TYPE_RCONFLICTS :   ("conflicts", "%s conflicts with %s, which will not be installed if this package is not first removed"),
     }
 
-    package = models.ForeignKey(Package, related_name='package_dependencies_source')
-    depends_on = models.ForeignKey(Package, related_name='package_dependencies_target')   # soft dependency
+    package = models.ForeignKey(Package, on_delete=models.CASCADE, related_name='package_dependencies_source')
+    depends_on = models.ForeignKey(Package, on_delete=models.CASCADE, related_name='package_dependencies_target')   # soft dependency
     dep_type = models.IntegerField(choices=DEPENDS_TYPE)
-    target = models.ForeignKey(Target, null=True)
+    target = models.ForeignKey(Target, on_delete=models.CASCADE, null=True)
     objects = Package_DependencyManager()
 
 class Target_Installed_Package(models.Model):
-    target = models.ForeignKey(Target)
-    package = models.ForeignKey(Package, related_name='buildtargetlist_package')
+    target = models.ForeignKey(Target, on_delete=models.CASCADE)
+    package = models.ForeignKey(Package, on_delete=models.CASCADE, related_name='buildtargetlist_package')
 
 
 class Package_File(models.Model):
-    package = models.ForeignKey(Package, related_name='buildfilelist_package')
+    package = models.ForeignKey(Package, on_delete=models.CASCADE, related_name='buildfilelist_package')
     path = models.FilePathField(max_length=255, blank=True)
     size = models.IntegerField()
 
@@ -1318,7 +1318,7 @@
 
     name = models.CharField(max_length=100, blank=True)
     version = models.CharField(max_length=100, blank=True)
-    layer_version = models.ForeignKey('Layer_Version',
+    layer_version = models.ForeignKey('Layer_Version', on_delete=models.CASCADE,
                                       related_name='recipe_layer_version')
     summary = models.TextField(blank=True)
     description = models.TextField(blank=True)
@@ -1356,7 +1356,7 @@
 
 class Provides(models.Model):
     name = models.CharField(max_length=100)
-    recipe = models.ForeignKey(Recipe)
+    recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
 
 class Recipe_Dependency(models.Model):
     TYPE_DEPENDS = 0
@@ -1366,9 +1366,9 @@
         (TYPE_DEPENDS, "depends"),
         (TYPE_RDEPENDS, "rdepends"),
     )
-    recipe = models.ForeignKey(Recipe, related_name='r_dependencies_recipe')
-    depends_on = models.ForeignKey(Recipe, related_name='r_dependencies_depends')
-    via = models.ForeignKey(Provides, null=True, default=None)
+    recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, related_name='r_dependencies_recipe')
+    depends_on = models.ForeignKey(Recipe, on_delete=models.CASCADE, related_name='r_dependencies_depends')
+    via = models.ForeignKey(Provides, on_delete=models.CASCADE, null=True, default=None)
     dep_type = models.IntegerField(choices=DEPENDS_TYPE)
     objects = Recipe_DependencyManager()
 
@@ -1377,7 +1377,7 @@
     search_allowed_fields = ["name", "description", "layer_version__layer__name"]
     up_date = models.DateTimeField(null = True, default = None)
 
-    layer_version = models.ForeignKey('Layer_Version')
+    layer_version = models.ForeignKey('Layer_Version', on_delete=models.CASCADE)
     name = models.CharField(max_length=255)
     description = models.CharField(max_length=255)
 
@@ -1408,7 +1408,7 @@
     """ A release is a project template, used to pre-populate Project settings with a configuration set """
     name = models.CharField(max_length=32, unique = True)
     description = models.CharField(max_length=255)
-    bitbake_version = models.ForeignKey(BitbakeVersion)
+    bitbake_version = models.ForeignKey(BitbakeVersion, on_delete=models.CASCADE)
     branch_name = models.CharField(max_length=50, default = "")
     helptext = models.TextField(null=True)
 
@@ -1419,7 +1419,7 @@
         return self.name
 
 class ReleaseDefaultLayer(models.Model):
-    release = models.ForeignKey(Release)
+    release = models.ForeignKey(Release, on_delete=models.CASCADE)
     layer_name = models.CharField(max_length=100, default="")
 
 
@@ -1474,10 +1474,10 @@
                              "layer__description", "layer__vcs_url",
                              "dirpath", "release__name", "commit", "branch"]
 
-    build = models.ForeignKey(Build, related_name='layer_version_build',
+    build = models.ForeignKey(Build, on_delete=models.CASCADE, related_name='layer_version_build',
                               default=None, null=True)
 
-    layer = models.ForeignKey(Layer, related_name='layer_version_layer')
+    layer = models.ForeignKey(Layer, on_delete=models.CASCADE, related_name='layer_version_layer')
 
     layer_source = models.IntegerField(choices=LayerSource.SOURCE_TYPE,
                                        default=0)
@@ -1485,7 +1485,7 @@
     up_date = models.DateTimeField(null=True, default=timezone.now)
 
     # To which metadata release does this layer version belong to
-    release = models.ForeignKey(Release, null=True, default=None)
+    release = models.ForeignKey(Release, on_delete=models.CASCADE, null=True, default=None)
 
     branch = models.CharField(max_length=80)
     commit = models.CharField(max_length=100)
@@ -1499,7 +1499,7 @@
     local_path = models.FilePathField(max_length=1024, default="/")
 
     # Set if this layer is restricted to a particular project
-    project = models.ForeignKey('Project', null=True, default=None)
+    project = models.ForeignKey('Project', on_delete=models.CASCADE, null=True, default=None)
 
     # code lifted, with adaptations, from the layerindex-web application
     # https://git.yoctoproject.org/cgit/cgit.cgi/layerindex-web/
@@ -1608,14 +1608,14 @@
 
 class LayerVersionDependency(models.Model):
 
-    layer_version = models.ForeignKey(Layer_Version,
+    layer_version = models.ForeignKey(Layer_Version, on_delete=models.CASCADE,
                                       related_name="dependencies")
-    depends_on = models.ForeignKey(Layer_Version,
+    depends_on = models.ForeignKey(Layer_Version, on_delete=models.CASCADE,
                                    related_name="dependees")
 
 class ProjectLayer(models.Model):
-    project = models.ForeignKey(Project)
-    layercommit = models.ForeignKey(Layer_Version, null=True)
+    project = models.ForeignKey(Project, on_delete=models.CASCADE)
+    layercommit = models.ForeignKey(Layer_Version, on_delete=models.CASCADE, null=True)
     optional = models.BooleanField(default = True)
 
     def __unicode__(self):
@@ -1630,8 +1630,8 @@
     LAYER_NAME = "toaster-custom-images"
 
     search_allowed_fields = ['name']
-    base_recipe = models.ForeignKey(Recipe, related_name='based_on_recipe')
-    project = models.ForeignKey(Project)
+    base_recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, related_name='based_on_recipe')
+    project = models.ForeignKey(Project, on_delete=models.CASCADE)
     last_updated = models.DateTimeField(null=True, default=None)
 
     def get_last_successful_built_target(self):
@@ -1647,14 +1647,14 @@
         """
         # Check if we're aldready up-to-date or not
         target = self.get_last_successful_built_target()
-        if target == None:
+        if target is None:
             # So we've never actually built this Custom recipe but what about
             # the recipe it's based on?
             target = \
                 Target.objects.filter(Q(build__outcome=Build.SUCCEEDED) &
                                       Q(build__project=self.project) &
                                       Q(target=self.base_recipe.name)).last()
-            if target == None:
+            if target is None:
                 return
 
         if target.build.completed_on == self.last_updated:
@@ -1784,14 +1784,14 @@
         return recipe_contents
 
 class ProjectVariable(models.Model):
-    project = models.ForeignKey(Project)
+    project = models.ForeignKey(Project, on_delete=models.CASCADE)
     name = models.CharField(max_length=100)
     value = models.TextField(blank = True)
 
 class Variable(models.Model):
     search_allowed_fields = ['variable_name', 'variable_value',
                              'vhistory__file_name', "description"]
-    build = models.ForeignKey(Build, related_name='variable_build')
+    build = models.ForeignKey(Build, on_delete=models.CASCADE, related_name='variable_build')
     variable_name = models.CharField(max_length=100)
     variable_value = models.TextField(blank=True)
     changed = models.BooleanField(default=False)
@@ -1799,7 +1799,7 @@
     description = models.TextField(blank=True)
 
 class VariableHistory(models.Model):
-    variable = models.ForeignKey(Variable, related_name='vhistory')
+    variable = models.ForeignKey(Variable, on_delete=models.CASCADE, related_name='vhistory')
     value   = models.TextField(blank=True)
     file_name = models.FilePathField(max_length=255)
     line_number = models.IntegerField(null=True)
@@ -1809,7 +1809,7 @@
     VARIABLE = 0
     HELPTEXT_AREA = ((VARIABLE, 'variable'), )
 
-    build = models.ForeignKey(Build, related_name='helptext_build')
+    build = models.ForeignKey(Build, on_delete=models.CASCADE, related_name='helptext_build')
     area = models.IntegerField(choices=HELPTEXT_AREA)
     key = models.CharField(max_length=100)
     text = models.TextField()
@@ -1829,8 +1829,8 @@
         (EXCEPTION, "toaster exception")
     )
 
-    build = models.ForeignKey(Build)
-    task  = models.ForeignKey(Task, blank = True, null=True)
+    build = models.ForeignKey(Build, on_delete=models.CASCADE)
+    task  = models.ForeignKey(Task, on_delete=models.CASCADE, blank = True, null=True)
     level = models.IntegerField(choices=LOG_LEVEL, default=INFO)
     message = models.TextField(blank=True, null=True)
     pathname = models.FilePathField(max_length=255, blank=True)
@@ -1859,7 +1859,7 @@
     search_allowed_fields = ["name", "description", "layer_version__layer__name"]
     up_date = models.DateTimeField(null = True, default = None)
 
-    layer_version = models.ForeignKey('Layer_Version')
+    layer_version = models.ForeignKey('Layer_Version', on_delete=models.CASCADE)
     name = models.CharField(max_length=255)
     description = models.CharField(max_length=255)
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/poky/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py
index 6c94684..644d45f 100644
--- a/poky/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py
+++ b/poky/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py
@@ -19,7 +19,6 @@
 import time
 import unittest
 
-from django.contrib.staticfiles.testing import StaticLiveServerTestCase
 from selenium import webdriver
 from selenium.webdriver.support.ui import WebDriverWait
 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_all_builds_page.py b/poky/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
index fba627b..8423d3d 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_all_builds_page.py
@@ -9,7 +9,7 @@
 
 import re
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_all_projects_page.py b/poky/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
index afd2d35..15b0340 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_all_projects_page.py
@@ -9,7 +9,7 @@
 
 import re
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
index d972aff..efcd89b 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 
 from tests.browser.selenium_helpers import SeleniumTestCase
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
index e2623e8..c6226d6 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_artifacts.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 
 from tests.browser.selenium_helpers import SeleniumTestCase
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_recipes.py b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_recipes.py
index c542d45..9d85ba9 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_recipes.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_recipes.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 from orm.models import Project, Build, Recipe, Task, Layer, Layer_Version
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_tasks.py b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_tasks.py
index 22acb47..7fdf75d 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_tasks.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_builddashboard_page_tasks.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 from orm.models import Project, Build, Recipe, Task, Layer, Layer_Version
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_js_unit_tests.py b/poky/bitbake/lib/toaster/tests/browser/test_js_unit_tests.py
index e8b4295..e6163bb 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_js_unit_tests.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_js_unit_tests.py
@@ -11,7 +11,7 @@
 Run the js unit tests
 """
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 import logging
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_landing_page.py b/poky/bitbake/lib/toaster/tests/browser/test_landing_page.py
index 0790198..8bb64b9 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_landing_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_landing_page.py
@@ -7,7 +7,7 @@
 # Copyright (C) 2013-2016 Intel Corporation
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/poky/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
index f81e696..71bdd2a 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
@@ -7,7 +7,7 @@
 # Copyright (C) 2013-2016 Intel Corporation
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 
 from orm.models import Layer, Layer_Version, Project, LayerSource, Release
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py b/poky/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
index 15d25dc..7844aaa 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_most_recent_builds_states.py
@@ -7,7 +7,7 @@
 # Copyright (C) 2013-2016 Intel Corporation
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 from tests.browser.selenium_helpers_base import Wait
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py b/poky/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
index 0aa3b7a..9906ae4 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_new_custom_image_page.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 
 from orm.models import BitbakeVersion, Release, Project, ProjectLayer, Layer
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_new_project_page.py b/poky/bitbake/lib/toaster/tests/browser/test_new_project_page.py
index 8e56bb0..e20a1f6 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_new_project_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_new_project_page.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 from selenium.webdriver.support.ui import Select
 from selenium.common.exceptions import InvalidElementStateException
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_project_builds_page.py b/poky/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
index 47fb10b..51717e7 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_project_builds_page.py
@@ -9,7 +9,7 @@
 
 import re
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_project_config_page.py b/poky/bitbake/lib/toaster/tests/browser/test_project_config_page.py
index 2816eb9..944bcb2 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_project_config_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_project_config_page.py
@@ -7,10 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-import re
-
-from django.core.urlresolvers import reverse
-from django.utils import timezone
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 
 from orm.models import BitbakeVersion, Release, Project, ProjectVariable
@@ -216,4 +213,5 @@
 
         hidden_element = self.driver.find_element_by_id('hintError-sstate_dir')
         self.assertEqual(hidden_element.is_displayed(), False,
-            'sstate directory path valid but treated as invalid')
\ No newline at end of file
+            'sstate directory path valid but treated as invalid')
+
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_project_page.py b/poky/bitbake/lib/toaster/tests/browser/test_project_page.py
index 8b5e1b6..546293f 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_project_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_project_page.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_sample.py b/poky/bitbake/lib/toaster/tests/browser/test_sample.py
index f4ad670..b0067c2 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_sample.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_sample.py
@@ -16,7 +16,7 @@
 and should be in the same directory as this sample.
 """
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from tests.browser.selenium_helpers import SeleniumTestCase
 
 class TestSample(SeleniumTestCase):
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_task_page.py b/poky/bitbake/lib/toaster/tests/browser/test_task_page.py
index 26f3dca..011b585 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_task_page.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_task_page.py
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 from orm.models import Project, Build, Layer, Layer_Version, Recipe, Target
diff --git a/poky/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py b/poky/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
index ef78cbb..e82d5ec 100644
--- a/poky/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
+++ b/poky/bitbake/lib/toaster/tests/browser/test_toastertable_ui.py
@@ -9,7 +9,7 @@
 
 from datetime import datetime
 
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.utils import timezone
 from tests.browser.selenium_helpers import SeleniumTestCase
 from orm.models import BitbakeVersion, Release, Project, Build
diff --git a/poky/bitbake/lib/toaster/tests/functional/test_functional_basic.py b/poky/bitbake/lib/toaster/tests/functional/test_functional_basic.py
index 56c84fb..5683e38 100644
--- a/poky/bitbake/lib/toaster/tests/functional/test_functional_basic.py
+++ b/poky/bitbake/lib/toaster/tests/functional/test_functional_basic.py
@@ -7,7 +7,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-import time
 import re
 from tests.functional.functional_helpers import SeleniumFunctionalTestCase
 from orm.models import Project
diff --git a/poky/bitbake/lib/toaster/tests/views/test_views.py b/poky/bitbake/lib/toaster/tests/views/test_views.py
index 68d9e9d..735d596 100644
--- a/poky/bitbake/lib/toaster/tests/views/test_views.py
+++ b/poky/bitbake/lib/toaster/tests/views/test_views.py
@@ -11,7 +11,7 @@
 
 from django.test import TestCase
 from django.test.client import RequestFactory
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.db.models import Q
 
 from orm.models import Project, Package
diff --git a/poky/bitbake/lib/toaster/toastergui/api.py b/poky/bitbake/lib/toaster/toastergui/api.py
index 8b49b3e..b4cdc33 100644
--- a/poky/bitbake/lib/toaster/toastergui/api.py
+++ b/poky/bitbake/lib/toaster/toastergui/api.py
@@ -13,7 +13,6 @@
 import json
 import subprocess
 from collections import Counter
-from shutil import copyfile
 
 from orm.models import Project, ProjectTarget, Build, Layer_Version
 from orm.models import LayerVersionDependency, LayerSource, ProjectLayer
@@ -25,12 +24,10 @@
 
 from django.http import HttpResponse, JsonResponse
 from django.views.generic import View
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.db.models import Q, F
 from django.db import Error
 from toastergui.templatetags.projecttags import filtered_filesizeformat
-from django.utils import timezone
-import pytz
 
 # development/debugging support
 verbose = 2
diff --git a/poky/bitbake/lib/toaster/toastergui/tables.py b/poky/bitbake/lib/toaster/toastergui/tables.py
index b3ea222..528dd32 100644
--- a/poky/bitbake/lib/toaster/toastergui/tables.py
+++ b/poky/bitbake/lib/toaster/toastergui/tables.py
@@ -7,15 +7,10 @@
 #
 
 from toastergui.widgets import ToasterTable
-from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project
+from orm.models import Recipe, ProjectLayer, Layer_Version, Project
 from orm.models import CustomImageRecipe, Package, Target, Build, LogMessage, Task
 from orm.models import CustomImagePackage, Package_DependencyManager
-from orm.models import Distro
-from django.db.models import Q, Max, Sum, Count, When, Case, Value, IntegerField
-from django.conf.urls import url
-from django.core.urlresolvers import reverse, resolve
-from django.http import HttpResponse
-from django.views.generic import TemplateView
+from django.db.models import Q, Sum, Count, When, Case, Value, IntegerField
 
 from toastergui.tablefilter import TableFilter
 from toastergui.tablefilter import TableFilterActionToggle
diff --git a/poky/bitbake/lib/toaster/toastergui/templatetags/objects_to_dictionaries_filter.py b/poky/bitbake/lib/toaster/toastergui/templatetags/objects_to_dictionaries_filter.py
index 048d533..e242234 100644
--- a/poky/bitbake/lib/toaster/toastergui/templatetags/objects_to_dictionaries_filter.py
+++ b/poky/bitbake/lib/toaster/toastergui/templatetags/objects_to_dictionaries_filter.py
@@ -3,7 +3,6 @@
 #
 
 from django import template
-import json
 
 register = template.Library()
 
diff --git a/poky/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py b/poky/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
index 71e0925..7b6f15b 100644
--- a/poky/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
+++ b/poky/bitbake/lib/toaster/toastergui/templatetags/project_url_tag.py
@@ -3,7 +3,7 @@
 #
 
 from django import template
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 
 register = template.Library()
 
diff --git a/poky/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/poky/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
index 1dbab3b..c432f59 100644
--- a/poky/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/poky/bitbake/lib/toaster/toastergui/templatetags/projecttags.py
@@ -6,7 +6,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from datetime import datetime, timedelta
+from datetime import timedelta
 from os.path import relpath
 import re
 from django import template
@@ -44,7 +44,7 @@
     # it manually here
     return mark_safe(JsonLib.dumps(value, indent=2, default = default, ensure_ascii=False).replace('</', '<\\/'))
 
-@register.assignment_tag
+@register.simple_tag
 def query(qs, **kwargs):
     """ template tag which allows queryset filtering. Usage:
           {% query books author=author as mybooks %}
@@ -83,7 +83,7 @@
 def multiply(value, arg):
     return int(value) * int(arg)
 
-@register.assignment_tag
+@register.simple_tag
 def datecompute(delta, start = timezone.now()):
     return start + timedelta(delta)
 
@@ -212,7 +212,7 @@
     """If package.installed_size not null and not empty return it,
        else return package.size
     """
-    return size if (installed_size == 0) or (installed_size == "") or (installed_size == None) else installed_size
+    return size if (installed_size == 0) or (installed_size == "") or (installed_size is None) else installed_size
 
 @register.filter
 def filtered_packageversion(version, revision):
@@ -228,7 +228,7 @@
         formatted nicely.
     """
     size = package_object.installed_size
-    if size == None or size == '':
+    if size is None or size == '':
         size = package_object.size
 
     return '{:.1%}'.format(float(size)/float(total_size))
diff --git a/poky/bitbake/lib/toaster/toastergui/typeaheads.py b/poky/bitbake/lib/toaster/toastergui/typeaheads.py
index fd750ff..a1e6fe9 100644
--- a/poky/bitbake/lib/toaster/toastergui/typeaheads.py
+++ b/poky/bitbake/lib/toaster/toastergui/typeaheads.py
@@ -10,7 +10,7 @@
 
 from toastergui.widgets import ToasterTypeAhead
 from orm.models import Project
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 from django.core.cache import cache
 
 
diff --git a/poky/bitbake/lib/toaster/toastergui/urls.py b/poky/bitbake/lib/toaster/toastergui/urls.py
index 673d9ae..d2df4e6 100644
--- a/poky/bitbake/lib/toaster/toastergui/urls.py
+++ b/poky/bitbake/lib/toaster/toastergui/urls.py
@@ -6,10 +6,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.conf.urls import include, url
-from django.views.generic import RedirectView, TemplateView
+from django.conf.urls import url
+from django.views.generic import RedirectView
 
-from django.http import HttpResponseBadRequest
 from toastergui import tables
 from toastergui import buildtables
 from toastergui import typeaheads
diff --git a/poky/bitbake/lib/toaster/toastergui/views.py b/poky/bitbake/lib/toaster/toastergui/views.py
index d7acaff..9a5e48e 100644
--- a/poky/bitbake/lib/toaster/toastergui/views.py
+++ b/poky/bitbake/lib/toaster/toastergui/views.py
@@ -19,8 +19,8 @@
 from orm.models import TargetKernelFile, TargetSDKFile, Target_Image_File
 from orm.models import BitbakeVersion, CustomImageRecipe
 
-from django.core.urlresolvers import reverse, resolve
-from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
+from django.urls import reverse, resolve
+from django.core.exceptions import ObjectDoesNotExist
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 from django.http import HttpResponseNotFound, JsonResponse
 from django.utils import timezone
@@ -51,7 +51,7 @@
     def get_mimetype(self, path):
         guess = mimetypes.guess_type(path, self._strict)
         guessed_type = guess[0]
-        if guessed_type == None:
+        if guessed_type is None:
             guessed_type = 'application/octet-stream'
         return guessed_type
 
@@ -126,7 +126,7 @@
     return {"id": x.pk,
             "name": x.layer.name,
             "tooltip": "%s | %s" % (x.layer.vcs_url,x.get_vcs_reference()),
-            "detail": "(%s" % x.layer.vcs_url + (")" if x.release == None else " | "+x.get_vcs_reference()+")"),
+            "detail": "(%s" % x.layer.vcs_url + (")" if x.release is None else " | "+x.get_vcs_reference()+")"),
             "giturl": x.layer.vcs_url,
             "layerdetailurl" : reverse('layerdetails', args=(prj.id,x.pk)),
             "revision" : x.get_vcs_reference(),
@@ -352,7 +352,7 @@
 # set cookies for parameters. this is usefull in case parameters are set
 # manually from the GET values of the link
 def _set_parameters_values(pagesize, orderby, request):
-    from django.core.urlresolvers import resolve
+    from django.urls import resolve
     current_url = resolve(request.path_info).url_name
     request.session['%s_count' % current_url] = pagesize
     request.session['%s_orderby' % current_url] =orderby
@@ -664,7 +664,6 @@
     _set_parameters_values(pagesize, orderby, request)
     return response
 
-from django.core.serializers.json import DjangoJSONEncoder
 from django.http import HttpResponse
 def xhr_dirinfo(request, build_id, target_id):
     top = request.GET.get('start', '/')
@@ -719,7 +718,7 @@
                 resolved_id = o.sym_target_id
                 resolved_path = o.path
                 if target_packages.count():
-                    while resolved_id != "" and resolved_id != None:
+                    while resolved_id != "" and resolved_id is not None:
                         tf = Target_File.objects.get(pk=resolved_id)
                         resolved_path = tf.path
                         resolved_id = tf.sym_target_id
@@ -731,10 +730,10 @@
                         entry['package_id'] = str(p.id)
                         entry['package'] = p.name
                 # don't use resolved path from above, show immediate link-to
-                if o.sym_target_id != "" and o.sym_target_id != None:
+                if o.sym_target_id != "" and o.sym_target_id is not None:
                     entry['link_to'] = Target_File.objects.get(pk=o.sym_target_id).path
             entry['size'] = filtered_filesizeformat(o.size)
-            if entry['link_to'] != None:
+            if entry['link_to'] is not None:
                 entry['permission'] = node_str[o.inodetype] + o.permission
             else:
                 entry['permission'] = node_str[o.inodetype] + o.permission
@@ -756,7 +755,7 @@
     objects = _get_dir_entries(build_id, target_id, '/')
     packages_sum = Package.objects.filter(id__in=Target_Installed_Package.objects.filter(target_id=target_id).values('package_id')).aggregate(Sum('installed_size'))
     dir_list = None
-    if file_path != None:
+    if file_path is not None:
         """
         Link from the included package detail file list page and is
         requesting opening the dir info to a specific file path.
@@ -1030,15 +1029,15 @@
 
 def _get_package_alias(package):
     alias = package.installed_name
-    if alias != None and alias != '' and alias != package.name:
+    if alias is not None and alias != '' and alias != package.name:
         return alias
     else:
         return ''
 
 def _get_fullpackagespec(package):
     r = package.name
-    version_good = package.version != None and  package.version != ''
-    revision_good = package.revision != None and package.revision != ''
+    version_good = package.version is not None and  package.version != ''
+    revision_good = package.revision is not None and package.revision != ''
     if version_good or revision_good:
         r += '_'
         if version_good:
@@ -1192,7 +1191,7 @@
         return _redirect_parameters( 'package_included_reverse_dependencies', request.GET, mandatory_parameters, build_id = build_id, target_id = target_id, package_id = package_id)
     (filter_string, search_term, ordering_string) = _search_tuple(request, Package_File)
 
-    queryset = Package_Dependency.objects.select_related('depends_on__name', 'depends_on__size').filter(depends_on=package_id, target_id=target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
+    queryset = Package_Dependency.objects.select_related('depends_on').filter(depends_on=package_id, target_id=target_id, dep_type=Package_Dependency.TYPE_TRDEPENDS)
     objects = _get_queryset(Package_Dependency, queryset, filter_string, search_term, ordering_string, 'package__name')
 
     package = Package.objects.get(pk=package_id)
@@ -1340,7 +1339,7 @@
 
 import toastermain.settings
 
-from orm.models import Project, ProjectLayer, ProjectTarget, ProjectVariable
+from orm.models import Project, ProjectLayer, ProjectVariable
 from bldcontrol.models import  BuildEnvironment
 
 # we have a set of functions if we're in managed mode, or
@@ -1349,10 +1348,8 @@
 if True:
     from django.contrib.auth.models import User
     from django.contrib.auth import authenticate, login
-    from django.contrib.auth.decorators import login_required
 
-    from orm.models import LayerSource, ToasterSetting, Release, Machine, LayerVersionDependency
-    from bldcontrol.models import BuildRequest
+    from orm.models import LayerSource, ToasterSetting, Release
 
     import traceback
 
@@ -1367,8 +1364,8 @@
 
         template = "newproject.html"
         context = {
-            'email': request.user.email if request.user.is_authenticated() else '',
-            'username': request.user.username if request.user.is_authenticated() else '',
+            'email': request.user.email if request.user.is_authenticated else '',
+            'username': request.user.username if request.user.is_authenticated else '',
             'releases': Release.objects.order_by("description"),
         }
 
@@ -1394,7 +1391,7 @@
                     # set alert for missing fields
                     raise BadParameterException("Fields missing: %s" % ", ".join(missing))
 
-                if not request.user.is_authenticated():
+                if not request.user.is_authenticated:
                     user = authenticate(username = request.POST.get('username', '_anonuser'), password = 'nopass')
                     if user is None:
                         user = User.objects.create_user(username = request.POST.get('username', '_anonuser'), email = request.POST.get('email', ''), password = "nopass")
@@ -1441,8 +1438,8 @@
         project = Project.objects.get(pk=pid)
         template = "newproject_specific.html"
         context = {
-            'email': request.user.email if request.user.is_authenticated() else '',
-            'username': request.user.username if request.user.is_authenticated() else '',
+            'email': request.user.email if request.user.is_authenticated else '',
+            'username': request.user.username if request.user.is_authenticated else '',
             'releases': Release.objects.order_by("description"),
             'projectname': project.name,
             'project_pk': project.pk,
@@ -1472,7 +1469,7 @@
                     # set alert for missing fields
                     raise BadParameterException("Fields missing: %s" % ", ".join(missing))
 
-                if not request.user.is_authenticated():
+                if not request.user.is_authenticated:
                     user = authenticate(username = request.POST.get('username', '_anonuser'), password = 'nopass')
                     if user is None:
                         user = User.objects.create_user(username = request.POST.get('username', '_anonuser'), email = request.POST.get('email', ''), password = "nopass")
diff --git a/poky/bitbake/lib/toaster/toastergui/widgets.py b/poky/bitbake/lib/toaster/toastergui/widgets.py
index 645f458..ceff529 100644
--- a/poky/bitbake/lib/toaster/toastergui/widgets.py
+++ b/poky/bitbake/lib/toaster/toastergui/widgets.py
@@ -22,7 +22,7 @@
 from toastergui.templatetags.projecttags import sectohms, get_tasks
 from toastergui.templatetags.projecttags import json as template_json
 from django.http import JsonResponse
-from django.core.urlresolvers import reverse
+from django.urls import reverse
 
 import types
 import json
diff --git a/poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py b/poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
index c2d773a..93919de 100644
--- a/poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
+++ b/poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
@@ -2,12 +2,10 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
 from django.core.exceptions import ObjectDoesNotExist
 from orm.models import Build
 from django.db import OperationalError
-import os
-
 
 
 class Command(BaseCommand):
diff --git a/poky/bitbake/lib/toaster/toastermain/management/commands/buildimport.py b/poky/bitbake/lib/toaster/toastermain/management/commands/buildimport.py
index 408ad44..59da6ff 100644
--- a/poky/bitbake/lib/toaster/toastermain/management/commands/buildimport.py
+++ b/poky/bitbake/lib/toaster/toastermain/management/commands/buildimport.py
@@ -31,12 +31,10 @@
 
 # ../bitbake/lib/toaster/manage.py buildimport --name=test --path=`pwd` --callback="" --command=import
 
-from django.core.management.base import BaseCommand, CommandError
-from django.core.exceptions import ObjectDoesNotExist
-from orm.models import ProjectManager, Project, Release, ProjectVariable
+from django.core.management.base import BaseCommand
+from orm.models import Project, Release, ProjectVariable
 from orm.models import Layer, Layer_Version, LayerSource, ProjectLayer
 from toastergui.api import scan_layer_content
-from django.db import OperationalError
 
 import os
 import re
@@ -116,6 +114,15 @@
             help='command (configure,reconfigure,import)',
             )
 
+    def get_var(self, varname):
+        value = self.vars.get(varname, '')
+        if value:
+            varrefs = re.findall('\${([^}]*)}', value)
+            for ref in varrefs:
+                if ref in self.vars:
+                    value = value.replace('${%s}' % ref, self.vars[ref])
+        return value
+
     # Extract the bb variables from a conf file
     def scan_conf(self,fn):
         vars = self.vars
@@ -243,7 +250,7 @@
     # Apply table of all layer versions
     def extract_bblayers(self):
         # set up the constants
-        bblayer_str = self.vars['BBLAYERS']
+        bblayer_str = self.get_var('BBLAYERS')
         TOASTER_DIR = os.environ.get('TOASTER_DIR')
         INSTALL_CLONE_PREFIX = os.path.dirname(TOASTER_DIR) + "/"
         TOASTER_CLONE_PREFIX = TOASTER_DIR + "/_toaster_clones/"
@@ -423,6 +430,7 @@
 
     # Scan the project's conf files (if any)
     def scan_conf_variables(self,project_path):
+        self.vars['TOPDIR'] = project_path
         # scan the project's settings, add any new layers or variables
         if os.path.isfile("%s/conf/local.conf" % project_path):
             self.scan_conf("%s/conf/local.conf" % project_path)
@@ -468,7 +476,6 @@
                     release_name = 'None' if not pl.layercommit.release else pl.layercommit.release.name
                     print(" AFTER :ProjectLayer=%s,%s,%s,%s" % (pl.layercommit.layer.name,release_name,pl.layercommit.branch,pl.layercommit.commit))
 
-
     def handle(self, *args, **options):
         project_name = options['name']
         project_path = options['path']
@@ -507,7 +514,7 @@
         default_release = Release.objects.get(id=1)
 
         # SANITY: if 'reconfig' but project does not exist (deleted externally), switch to 'import'
-        if ("reconfigure" == options['command']) and (None == project):
+        if ("reconfigure" == options['command']) and project is None:
             options['command'] = 'import'
 
         # 'Configure':
@@ -553,6 +560,7 @@
             # preset the mode and default image recipe
             project.set_variable(Project.PROJECT_SPECIFIC_ISNEW,Project.PROJECT_SPECIFIC_NEW)
             project.set_variable(Project.PROJECT_SPECIFIC_DEFAULTIMAGE,"core-image-minimal")
+
             # Assert any extended/custom actions or variables for new non-Toaster projects
             if not len(self.toaster_vars):
                 pass
diff --git a/poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py b/poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
index 1ed2022..3ad5289 100644
--- a/poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
+++ b/poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py
@@ -2,9 +2,8 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
 from orm.models import Build
-import os
 
 
 
diff --git a/poky/bitbake/lib/toaster/toastermain/settings.py b/poky/bitbake/lib/toaster/toastermain/settings.py
index 74501fa..a4b370c 100644
--- a/poky/bitbake/lib/toaster/toastermain/settings.py
+++ b/poky/bitbake/lib/toaster/toastermain/settings.py
@@ -189,15 +189,16 @@
     },
 ]
 
-MIDDLEWARE_CLASSES = (
+MIDDLEWARE = [
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
-    # Uncomment the next line for simple clickjacking protection:
-    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
-)
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+]
 
 CACHES = {
     #        'default': {
@@ -248,7 +249,7 @@
 if os.environ.get('TOASTER_DEVEL', None) is not None:
     try:
         import fresh
-        MIDDLEWARE_CLASSES = ("fresh.middleware.FreshMiddleware",) + MIDDLEWARE_CLASSES
+        MIDDLEWARE = ["fresh.middleware.FreshMiddleware",] + MIDDLEWARE
         INSTALLED_APPS = INSTALLED_APPS + ('fresh',)
         FRESH_ENABLED = True
     except:
@@ -258,8 +259,8 @@
 if os.environ.get('TOASTER_DEVEL', None) is not None:
     try:
         import debug_toolbar, debug_panel
-        MIDDLEWARE_CLASSES = ('debug_panel.middleware.DebugPanelMiddleware',) + MIDDLEWARE_CLASSES
-        #MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+        MIDDLEWARE = ['debug_panel.middleware.DebugPanelMiddleware',] + MIDDLEWARE
+        #MIDDLEWARE = MIDDLEWARE + ['debug_toolbar.middleware.DebugToolbarMiddleware',]
         INSTALLED_APPS = INSTALLED_APPS + ('debug_toolbar','debug_panel',)
         DEBUG_PANEL_ENABLED = True
 
@@ -352,5 +353,3 @@
 connection_created.connect(activate_synchronous_off)
 #
 
-
-
diff --git a/poky/bitbake/lib/toaster/toastermain/urls.py b/poky/bitbake/lib/toaster/toastermain/urls.py
index ac77bc3..5fb520b 100644
--- a/poky/bitbake/lib/toaster/toastermain/urls.py
+++ b/poky/bitbake/lib/toaster/toastermain/urls.py
@@ -51,7 +51,7 @@
 
 urlpatterns = [
     # Uncomment the next line to enable the admin:
-    url(r'^admin/', include(admin.site.urls)),
+    url(r'^admin/', admin.site.urls),
 ] + urlpatterns
 
 # Automatically discover urls.py in various apps, beside our own
@@ -69,7 +69,7 @@
         # make sure we don't have this module name in
         conflict = False
         for p in urlpatterns:
-            if p.regex.pattern == '^' + modulename + '/':
+            if p.pattern.regex.pattern == '^' + modulename + '/':
                 conflict = True
         if not conflict:
             urlpatterns.insert(0, url(r'^' + modulename + '/', include ( modulename + '.urls')))