I have 3 three shapefiles and would like to upload all of them and project the result in GeoDjango admin.

a) state.shp (for the shape of a state)
b) boundary.shp (to identify a specific portion in the state.shp)
c) beat.shp (to further sub divide the region obtained from boundary.shp file)

What I want to do is the following:

Uploading state.shp gives the following result.

enter image description here

Uploading boundary.shp gives the following result:

enter image description here Please note new operations are performed on results obtained by previous operations. shapefile can be of different types (i.e poly, lines or points).

And similarly any other shapefile file which is uploaded should be projected. After following the official documentation I can project single shapefile in GeoDjango admin.

If I create separate models for each shapefile I will not get combined result.

How can I display result of multiple shapefile in GeoDjango?

EDIT: I want my end result to look something like this (load all shapefiles on openstreetmap in GeoDjango)

enter image description here

But however I can load single shapefile only (one shapefile at a time). Something like this

state.shp enter image description here boundary.shp enter image description here

I would like to combine both of my results in a single result as shown in QGIS output.

  • 1
    What do you mean by "project"? Do you mean change the map projection? Why have you posted three QGIS screenshots and no Django Admin screenshots?
    – Spacedman
    Commented Jun 8, 2019 at 7:04
  • 2
    By project I mean to display it on openstreetmap map and have a look at updated section.
    – neferpitou
    Commented Jun 8, 2019 at 7:22
  • 1
    As Spacedman said, the word "project" has a very specific meaning on this site, I suggest you replace is with "display" :). Similarly "shapefile" refers specifically to the file format, once you've loaded the shapefile into PostGIS it is a "geometry" or a "feature". Semantics aside, you might get an answer if you upload your Django models.
    – Alexander
    Commented Jun 11, 2019 at 16:27
  • 1
    You probably can't do this in the Django Admin area, one record can be edited at a time. Maybe a custom template can be used to show all imported shapefiles.
    – TheVRChris
    Commented Feb 20, 2020 at 19:42

1 Answer 1


In my case I created a template where I load both data in the form of geojson using url created in url.py

from django.shortcuts import render
from django.views.generic import TemplateView
from django.core.serializers import serialize
from django.http import HttpResponse
from .models import County

# Create your views here.

class HomePageView(TemplateView):
    template_name='index.html'  #the template name in template folder

#state dataset

def state_datasets(request):
    state=serialize('geojson',State.objects.all()) #converts the shapefile loaded to geojson
    return HttpResponse(state,content_type='application/json')

#beat dataset

def beat_datasets(request):
    beat=serialize('geojson',Beat.objects.all()) #converts the shapefile loaded to geojson
    return HttpResponse(beat,content_type='application/json')


from django.conf.urls import url
from djgeojson.views import GeoJSONLayerView
from .views import HomePageView,beat_datasets,state_dataset

    url(r'^state_data/$',state_datasets,name='state') #state url
url(r'^beat_data/$',beat_datasets,name='beat') #the url beat

Make sure you add this line below in your setting at the template:

 'DIRS': [os.path.join(BASE_DIR,'templates')],

Then create a templates folder with index.html file:


<!DOCTYPE html>
<html lang="en">

{% load static %}
{% load leaflet_tags %}


    {% leaflet_js %}
    {% leaflet_css %}

   <script src="{% static 'ajax/leaflet.ajax.js' %}"></script>


                function our_layers(map,options){

                    // adding open street map

                    var osm = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}{y}{x}.png');
                    // loading state geojson

                    var state = new L.GeoJSON.AJAX("{% url 'state' %}",{


                     var beat = new L.GeoJSON.AJAX("{% url 'beat' %}",{



   {% leaflet_map "gis" callback="window.our_layers" %}


#make sure you have leaflet ajax plugin ,django-leaflet (pip install django-leaflet)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.