This is a Django-based web application for managing farm data. It allows users to perform CRUD operations on farming models, such as Crops and Animals, and integrates GIS functionality using GDAL and SpatiaLite. The project was completed in three assignments:
-
Assignment 1: Django models, migrations, and admin customisation
-
Assignment 2: Wildlife app + Django ORM queries
-
Assignment 3: Views, templates, and CRUD functionality
-
Assignment 4: Function-Based Views (FBVs), BaseModel for shared fields, pagination, success messages, and improved UI
-
Assignment 5: ORM Testing using Django’s built-in testing framework
- CRUD operations for Farm Locations, Crops, and Irrigation Zones
- BaseModel with last_update (auto-update timestamp) and last_update_by (tracks user who last modified a record)
- Pagination on list views (10 items per page) -Success messages on create/update/delete actions
- User-friendly navigation and intuitive interface
- Django Admin integration with read-only tracking fields
- GIS support using GDAL
- Fully automated Django tests for ORM queries (Assignment 5)
git clone https://github.com/nikita-harripersadh/django-gis.git
cd django-gispython -m venv venv
venv\Scripts\activate # Windowspip install -r requirements.txtpython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py runserverUse the custom Django command:
python manage.py run_ormAll 12 ORM tasks are implemented in:
wildlife/management/commands/run_orm.pyTwo models from the farming app have full CRUD operations using Class-Based Views:
Views Used
ListView
DetailView
CreateView
UpdateView
DeleteViewtemplates/
farming/
model_list.html
model_detail.html
model_form.html
model_confirm_delete.htmlpath("farms/", FarmListView.as_view(), name="farm-list"),
path("farms/<int:pk>/", FarmDetailView.as_view(), name="farm-detail"),Features:
Paginated list views
Auto-update last_update and last_update_by
Success messages
Clean UI templatespath("farms/", farm_list, name="farm_list"),
path("farms/add/", farm_create, name="farm_create"),
path("farms/<int:pk>/", farm_detail, name="farm_detail"),
path("farms/<int:pk>/edit/", farm_update, name="farm_update"),
path("farms/<int:pk>/delete/", farm_delete, name="farm_delete"),farm/templates/farm/
farmlocation_list.html
farmlocation_detail.html
farmlocation_form.html
farmlocation_confirm_delete.html
crop_list.html
crop_detail.html
crop_form.html
crop_confirm_delete.html
zone_list.html
zone_detail.html
zone_form.html
zone_confirm_delete.htmlCustom admin classes:
list_display
list_filter
search_fields
readonly_fields for last_update and last_update_byA full automated test suite was implemented to validate ORM queries from Assignment 2.
All tests are located in:
wildlife/tests.py
Run tests:
python manage.py test wildlifeThe project follows the lesson-based branching:
django-lesson-1-admin
django-lesson-2-orm
django-lesson-3-cbv
django-lesson-4-fbv
django-lesson-5-testGDAL does not install cleanly on Windows with the latest Python versions (e.g., Python 3.12+). To avoid installation errors, this project uses a dedicated Conda environment with a compatible Python version.
Follow the steps below to set up GDAL and run this Django GIS project successfully.
Download Miniconda (Restart after install)GDAL works best with Python 3.10 or 3.11 on Windows.
Open Anaconda Prompt or VS Code terminal
conda create -n gdal-env python=3.10conda activate gdal-envYou should see:
(gdal-env) C:\Users\yourname>conda install -c conda-forge gdalInside the gdal-env environment:
pip install djangoInside VS Code terminal:
python -c "import osgeo; print(osgeo.__version__)"You should see a version number like:
3.6.2Navigate to your project folder:
cd path/to/your/projectRun migrations:
python manage.py migrateStart the Django development server:
python manage.py runserver