830a056cf89ac170c6ab99fa96caf63d6def2a64
LaTiendaCOOP backend
This README aims to document functionality of backend as well as required steps to get it up and running.
Table of Contents
First Steps
- Clone repository:
git clone git@bitbucket.org:enreda/back-latienda.git - Create file
.envfromexample.envand populate fields correctly
From inside the project's folder:
- Make migrations:
python manage.py makemigrations core companies products history stats
python migrate
- Start server in development mode:
python manage.py runserver
Load Geo data
Import geodata
import os
from geo.models import Region
from django.contrib.gis.geos import GeometryCollection, GEOSGeometry
import json
from django.contrib.gis.geos import MultiPolygon
path='gadm36_ESP_1.json'
feature_collection = json.loads(open(path).read())
for feature in feature_collection['features']:
geom = GEOSGeometry(str(feature['geometry']))
if feature['geometry']['type'] == "MultiPolygon":
poly_list = []
for poly in geom:
poly_list.append(poly)
print(poly_list)
else:
poly_list = geom
geom_geos = MultiPolygon(poly_list)
name = feature['properties']['NAME_1']
region = Region.objects.create(name=name,geo=geom_geos)
region.save()
Description
Languages
Python
53.9%
HTML
46.1%