code: def make_dbsource(**kwargs):
      
      if 'spatialite' in connection.settings_dict.get('ENGINE'):
          kwargs.setdefault('file', connection.settings_dict['NAME'])
          return mapnik.SQLite(wkb_format='spatialite', **kwargs)
      names = (('dbname', 'NAME'), ('user', 'USER'),
               ('password', 'PASSWORD'), ('host', 'HOST'), ('port', 'PORT'))
      for mopt, dopt in names:
          val = connection.settings_dict.get(dopt)
          if val:
              kwargs.setdefault(mopt, val)
      return mapnik.PostGIS(**kwargs)
docs: Returns a mapnik PostGIS or SQLite Datasource.