Skip to content

Commit 89ffca8

Browse files
authored
Merge pull request #21 from techiediaries/location-based-web-app-geodjango
Location based web app geodjango
2 parents 69505b9 + 4e269c6 commit 89ffca8

File tree

17 files changed

+5358
-0
lines changed

17 files changed

+5358
-0
lines changed

nearbyshops/data.json

Lines changed: 5035 additions & 0 deletions
Large diffs are not rendered by default.

nearbyshops/manage.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nearbyshops.settings")
7+
try:
8+
from django.core.management import execute_from_command_line
9+
except ImportError as exc:
10+
raise ImportError(
11+
"Couldn't import Django. Are you sure it's installed and "
12+
"available on your PYTHONPATH environment variable? Did you "
13+
"forget to activate a virtual environment?"
14+
) from exc
15+
execute_from_command_line(sys.argv)

nearbyshops/nearbyshops/__init__.py

Whitespace-only changes.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
"""
2+
Django settings for nearbyshops project.
3+
4+
Generated by 'django-admin startproject' using Django 2.1.1.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/2.1/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = "+pdwy6_m&)^+8g!3%^_r7$&xr)$)mr7y_dznrq1h&a*-879#3s"
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
"django.contrib.admin",
35+
"django.contrib.auth",
36+
"django.contrib.contenttypes",
37+
"django.contrib.sessions",
38+
"django.contrib.messages",
39+
"django.contrib.staticfiles",
40+
"django.contrib.gis",
41+
"shops",
42+
]
43+
44+
MIDDLEWARE = [
45+
"django.middleware.security.SecurityMiddleware",
46+
"django.contrib.sessions.middleware.SessionMiddleware",
47+
"django.middleware.common.CommonMiddleware",
48+
"django.middleware.csrf.CsrfViewMiddleware",
49+
"django.contrib.auth.middleware.AuthenticationMiddleware",
50+
"django.contrib.messages.middleware.MessageMiddleware",
51+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
52+
]
53+
54+
ROOT_URLCONF = "nearbyshops.urls"
55+
56+
TEMPLATES = [
57+
{
58+
"BACKEND": "django.template.backends.django.DjangoTemplates",
59+
"DIRS": [os.path.join(BASE_DIR, "templates")],
60+
"APP_DIRS": True,
61+
"OPTIONS": {
62+
"context_processors": [
63+
"django.template.context_processors.debug",
64+
"django.template.context_processors.request",
65+
"django.contrib.auth.context_processors.auth",
66+
"django.contrib.messages.context_processors.messages",
67+
]
68+
},
69+
}
70+
]
71+
72+
WSGI_APPLICATION = "nearbyshops.wsgi.application"
73+
74+
75+
# Database
76+
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
77+
78+
DATABASES = {
79+
"default": {
80+
"ENGINE": "django.contrib.gis.db.backends.postgis",
81+
"NAME": "gis",
82+
"USER": "user001",
83+
"PASSWORD": "123456789",
84+
"HOST": "localhost",
85+
"PORT": "5432",
86+
}
87+
}
88+
89+
90+
# Password validation
91+
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
92+
93+
AUTH_PASSWORD_VALIDATORS = [
94+
{
95+
"NAME": "django.contrib.auth.password_validation"
96+
+ ".UserAttributeSimilarityValidator"
97+
},
98+
{
99+
"NAME": "django.contrib.auth.password_validation"
100+
+ ".MinimumLengthValidator"
101+
},
102+
{
103+
"NAME": "django.contrib.auth.password_validation"
104+
+ ".CommonPasswordValidator"
105+
},
106+
{
107+
"NAME": "django.contrib.auth.password_validation"
108+
+ ".NumericPasswordValidator"
109+
},
110+
]
111+
112+
113+
# Internationalization
114+
# https://docs.djangoproject.com/en/2.1/topics/i18n/
115+
116+
LANGUAGE_CODE = "en-us"
117+
118+
TIME_ZONE = "UTC"
119+
120+
USE_I18N = True
121+
122+
USE_L10N = True
123+
124+
USE_TZ = True
125+
126+
127+
# Static files (CSS, JavaScript, Images)
128+
# https://docs.djangoproject.com/en/2.1/howto/static-files/
129+
130+
STATIC_URL = "/static/"

nearbyshops/nearbyshops/urls.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""nearbyshops URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/2.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
from shops import views
20+
21+
urlpatterns = [path("", views.Home.as_view()), path("admin/", admin.site.urls)]

nearbyshops/nearbyshops/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for nearbyshops project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "nearbyshops.settings")
15+
16+
application = get_wsgi_application()

nearbyshops/readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Make a Location-Based Web App With Django and GeoDjango
2+
3+
This folder contains the bonus material & example projects for our [Make a Location-Based Web App With Django and GeoDjango](https://realpython.com/location-based-app-with-geodjango-tutorial) tutorial on Real Python.
4+

nearbyshops/shops/__init__.py

Whitespace-only changes.

nearbyshops/shops/admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Register your models here.
2+
3+
from django.contrib import admin
4+
from django.contrib.gis.admin import OSMGeoAdmin
5+
from .models import Shop
6+
7+
8+
@admin.register(Shop)
9+
class ShopAdmin(OSMGeoAdmin):
10+
list_display = ("name", "location")

nearbyshops/shops/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ShopsConfig(AppConfig):
5+
name = "shops"

0 commit comments

Comments
 (0)