├── .gitignore ├── A ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── settings.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── wsgi.cpython-38.pyc ├── asgi.py ├── schema.py ├── settings.py ├── urls.py └── wsgi.py ├── README.md ├── accounts ├── __init__.py ├── admin.py ├── apps.py ├── migrations │ └── __init__.py ├── models.py ├── schema.py ├── tests.py └── views.py ├── db.sqlite3 ├── home ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── admin.cpython-38.pyc │ ├── apps.cpython-38.pyc │ ├── models.cpython-38.pyc │ ├── urls.cpython-38.pyc │ └── views.cpython-38.pyc ├── admin.py ├── apps.py ├── migrations │ ├── 0001_initial.py │ ├── 0002_auto_20210125_1539.py │ ├── __init__.py │ └── __pycache__ │ │ └── __init__.cpython-38.pyc ├── models.py ├── schema.py ├── templates │ └── home │ │ └── home.html ├── tests.py ├── urls.py └── views.py ├── manage.py └── templates ├── base.html └── inc ├── messages.html └── navbar.html /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .idea/ 3 | 4 | -------------------------------------------------------------------------------- /A/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/A/__init__.py -------------------------------------------------------------------------------- /A/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/A/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /A/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/A/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /A/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/A/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /A/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/A/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /A/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for A project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'A.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /A/schema.py: -------------------------------------------------------------------------------- 1 | import graphene 2 | import home.schema 3 | import accounts.schema 4 | 5 | 6 | class Query(home.schema.HomeQuery, accounts.schema.AccountsQuery, graphene.ObjectType): 7 | pass 8 | 9 | 10 | class Mutation(home.schema.Mutate, accounts.schema.Mutation, graphene.ObjectType): 11 | pass 12 | 13 | 14 | schema = graphene.Schema(query=Query, mutation=Mutation) 15 | -------------------------------------------------------------------------------- /A/settings.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 4 | BASE_DIR = Path(__file__).resolve().parent.parent 5 | 6 | # SECURITY WARNING: keep the secret key used in production secret! 7 | SECRET_KEY = '-yq)a2gp8@w1n(ww6bf5@r83ze^288uiuo4^-)s+lc63j9-qji' 8 | 9 | # SECURITY WARNING: don't run with debug turned on in production! 10 | DEBUG = True 11 | 12 | ALLOWED_HOSTS = [] 13 | 14 | 15 | # Application definition 16 | 17 | INSTALLED_APPS = [ 18 | 'django.contrib.admin', 19 | 'django.contrib.auth', 20 | 'django.contrib.contenttypes', 21 | 'django.contrib.sessions', 22 | 'django.contrib.messages', 23 | 'django.contrib.staticfiles', 24 | 'home.apps.HomeConfig', 25 | 'accounts.apps.AccountsConfig', 26 | 'graphene_django', 27 | ] 28 | 29 | MIDDLEWARE = [ 30 | 'django.middleware.security.SecurityMiddleware', 31 | 'django.contrib.sessions.middleware.SessionMiddleware', 32 | 'django.middleware.common.CommonMiddleware', 33 | 'django.middleware.csrf.CsrfViewMiddleware', 34 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 35 | 'django.contrib.messages.middleware.MessageMiddleware', 36 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 37 | ] 38 | 39 | ROOT_URLCONF = 'A.urls' 40 | 41 | TEMPLATES = [ 42 | { 43 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 44 | 'DIRS': [BASE_DIR / 'templates'], 45 | 'APP_DIRS': True, 46 | 'OPTIONS': { 47 | 'context_processors': [ 48 | 'django.template.context_processors.debug', 49 | 'django.template.context_processors.request', 50 | 'django.contrib.auth.context_processors.auth', 51 | 'django.contrib.messages.context_processors.messages', 52 | ], 53 | }, 54 | }, 55 | ] 56 | 57 | WSGI_APPLICATION = 'A.wsgi.application' 58 | 59 | 60 | # Database 61 | # https://docs.djangoproject.com/en/3.1/ref/settings/#databases 62 | 63 | DATABASES = { 64 | 'default': { 65 | 'ENGINE': 'django.db.backends.sqlite3', 66 | 'NAME': BASE_DIR / 'db.sqlite3', 67 | } 68 | } 69 | 70 | 71 | # Password validation 72 | # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 73 | 74 | AUTH_PASSWORD_VALIDATORS = [ 75 | { 76 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 77 | }, 78 | { 79 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 80 | }, 81 | { 82 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 83 | }, 84 | { 85 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 86 | }, 87 | ] 88 | 89 | 90 | # Internationalization 91 | # https://docs.djangoproject.com/en/3.1/topics/i18n/ 92 | 93 | LANGUAGE_CODE = 'en-us' 94 | 95 | TIME_ZONE = 'UTC' 96 | 97 | USE_I18N = True 98 | 99 | USE_L10N = True 100 | 101 | USE_TZ = True 102 | 103 | 104 | # Static files (CSS, JavaScript, Images) 105 | # https://docs.djangoproject.com/en/3.1/howto/static-files/ 106 | 107 | STATIC_URL = '/static/' 108 | 109 | 110 | AUTHENTICATION_BACKENDS = [ 111 | 'graphql_jwt.backends.JSONWebTokenBackend', 112 | 'django.contrib.auth.backends.ModelBackend', 113 | ] 114 | 115 | GRAPHENE = { 116 | 'SCHEMA': 'A.schema.schema', 117 | 'MIDDLEWARE': [ 118 | 'graphql_jwt.middleware.JSONWebTokenMiddleware', 119 | ] 120 | } -------------------------------------------------------------------------------- /A/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | from graphene_django.views import GraphQLView 4 | from django.views.decorators.csrf import csrf_exempt 5 | 6 | 7 | urlpatterns = [ 8 | path('admin/', admin.site.urls), 9 | path('', include('home.urls', namespace='home')), 10 | path('api/', csrf_exempt(GraphQLView.as_view(graphiql=False))), 11 | ] 12 | -------------------------------------------------------------------------------- /A/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for A 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/3.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', 'A.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data. 2 | GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015. 3 | 4 | [read more](https://en.wikipedia.org/wiki/GraphQL) -------------------------------------------------------------------------------- /accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/accounts/__init__.py -------------------------------------------------------------------------------- /accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /accounts/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AccountsConfig(AppConfig): 5 | name = 'accounts' 6 | -------------------------------------------------------------------------------- /accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /accounts/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /accounts/schema.py: -------------------------------------------------------------------------------- 1 | import graphene 2 | import graphql_jwt 3 | from graphene_django.types import DjangoObjectType, ObjectType 4 | from django.contrib.auth.models import User 5 | from graphql_jwt.decorators import login_required 6 | 7 | 8 | class UserType(DjangoObjectType): 9 | class Meta: 10 | model = User 11 | 12 | 13 | class AccountsQuery(ObjectType): 14 | user = graphene.Field(UserType, id=graphene.ID()) 15 | 16 | @login_required 17 | def resolve_user(parent, info, **kwargs): 18 | id = kwargs.get('id') 19 | if id is not None: 20 | return User.objects.get(id=id) 21 | return None 22 | 23 | 24 | class UserInput(graphene.InputObjectType): 25 | username = graphene.String() 26 | email = graphene.String() 27 | password = graphene.String() 28 | 29 | 30 | class CreateUser(graphene.Mutation): 31 | class Arguments: 32 | input = UserInput(required=True) 33 | 34 | ok = graphene.Boolean(default_value=False) 35 | user = graphene.Field(UserType) 36 | 37 | @staticmethod 38 | def mutate(parent, info, input=None): 39 | user_instance = User.objects.create_user(input.username, input.email, input.password) 40 | ok = True 41 | return CreateUser(user=user_instance, ok=ok) 42 | 43 | 44 | class Mutation(graphene.ObjectType): 45 | create_user = CreateUser.Field() 46 | token_auth = graphql_jwt.ObtainJSONWebToken.Field() 47 | verify_token = graphql_jwt.Verify.Field() 48 | refresh_token = graphql_jwt.Refresh.Field() 49 | 50 | # eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InJvb3QiLCJleHAiOjE2MTMxMjcxMjcsIm9yaWdJYXQiOjE2MTMxMjY4Mjd9.BrySPzW7aYmUmWlK9G0U5y6NpNLZZ0iqjLCe6vicOrI -------------------------------------------------------------------------------- /accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /accounts/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/db.sqlite3 -------------------------------------------------------------------------------- /home/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__init__.py -------------------------------------------------------------------------------- /home/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /home/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /home/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /home/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /home/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /home/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /home/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Person, Car 3 | 4 | 5 | admin.site.register(Person) 6 | admin.site.register(Car) -------------------------------------------------------------------------------- /home/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class HomeConfig(AppConfig): 5 | name = 'home' 6 | -------------------------------------------------------------------------------- /home/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2021-01-21 14:45 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | initial = True 10 | 11 | dependencies = [ 12 | ] 13 | 14 | operations = [ 15 | migrations.CreateModel( 16 | name='Person', 17 | fields=[ 18 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 19 | ('name', models.CharField(max_length=100)), 20 | ('age', models.IntegerField()), 21 | ], 22 | ), 23 | migrations.CreateModel( 24 | name='Car', 25 | fields=[ 26 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 27 | ('name', models.CharField(max_length=100)), 28 | ('year', models.IntegerField()), 29 | ('person', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.person')), 30 | ], 31 | ), 32 | ] 33 | -------------------------------------------------------------------------------- /home/migrations/0002_auto_20210125_1539.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.1.4 on 2021-01-25 15:39 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('home', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.RemoveField( 14 | model_name='car', 15 | name='person', 16 | ), 17 | migrations.AddField( 18 | model_name='car', 19 | name='person', 20 | field=models.ManyToManyField(to='home.Person'), 21 | ), 22 | ] 23 | -------------------------------------------------------------------------------- /home/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/migrations/__init__.py -------------------------------------------------------------------------------- /home/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amirbigg/django-graphql/aa11c2835b5f5c8919ea5895dc6f4eaa8a06d48a/home/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /home/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | 4 | class Person(models.Model): 5 | name = models.CharField(max_length=100) 6 | age = models.IntegerField() 7 | 8 | def __str__(self): 9 | return self.name 10 | 11 | 12 | class Car(models.Model): 13 | person = models.ManyToManyField(Person) 14 | name = models.CharField(max_length=100) 15 | year = models.IntegerField() 16 | 17 | def __str__(self): 18 | return self.name 19 | -------------------------------------------------------------------------------- /home/schema.py: -------------------------------------------------------------------------------- 1 | import graphene 2 | from graphene_django.types import DjangoObjectType, ObjectType 3 | from .models import Person, Car 4 | 5 | 6 | class PersonType(DjangoObjectType): 7 | class Meta: 8 | model = Person 9 | 10 | 11 | class CarType(DjangoObjectType): 12 | class Meta: 13 | model = Car 14 | 15 | 16 | class HomeQuery(ObjectType): 17 | persons = graphene.List(PersonType) 18 | cars = graphene.List(CarType) 19 | person = graphene.Field(PersonType, name=graphene.String()) 20 | car = graphene.Field(CarType, id=graphene.Int()) 21 | 22 | def resolve_persons(parent, info, **kwargs): 23 | return Person.objects.all() 24 | 25 | def resolve_cars(parent, info, **kwargs): 26 | return Car.objects.all() 27 | 28 | def resolve_person(parent, info, **kwargs): 29 | name = kwargs.get('name') 30 | if name is not None: 31 | return Person.objects.get(name=name) 32 | return None 33 | 34 | def resolve_car(parent, info, **kwargs): 35 | id = kwargs.get('id') 36 | if id is not None: 37 | return Car.objects.get(id=id) 38 | return None 39 | 40 | 41 | class PersonInput(graphene.InputObjectType): 42 | name = graphene.String() 43 | age = graphene.Int() 44 | 45 | 46 | class CarInput(graphene.InputObjectType): 47 | persons_id = graphene.List(graphene.ID) 48 | name = graphene.String() 49 | year = graphene.Int() 50 | 51 | 52 | class CreatePerson(graphene.Mutation): 53 | class Arguments: 54 | input = PersonInput(required=True) 55 | 56 | person = graphene.Field(PersonType) 57 | ok = graphene.Boolean(default_value=False) 58 | 59 | @staticmethod 60 | def mutate(parent, info, input=None): 61 | person_instance = Person.objects.create(name=input.name, age=input.age) 62 | ok = True 63 | return CreatePerson(person=person_instance, ok=ok) 64 | 65 | 66 | class UpdatePerson(graphene.Mutation): 67 | class Arguments: 68 | id = graphene.Int(required=True) 69 | input = PersonInput() 70 | 71 | person = graphene.Field(PersonType) 72 | ok = graphene.Boolean(default_value=False) 73 | 74 | @staticmethod 75 | def mutate(parent, info, id, input=None): 76 | person_instance = Person.objects.get(id=id) 77 | person_instance.name = input.name if input.name is not None else person_instance.name 78 | person_instance.age = input.age if input.age is not None else person_instance.age 79 | person_instance.save() 80 | ok = True 81 | return UpdatePerson(person=person_instance, ok=ok) 82 | 83 | 84 | class DeletePerson(graphene.Mutation): 85 | class Arguments: 86 | id = graphene.ID() 87 | 88 | person = graphene.Field(PersonType) 89 | ok = graphene.Boolean(default_value=False) 90 | 91 | @staticmethod 92 | def mutate(parent, info, id): 93 | person_instance = Person.objects.get(id=id) 94 | person_instance.delete() 95 | ok = True 96 | return DeletePerson(person=person_instance, ok=ok) 97 | 98 | 99 | class CreateCar(graphene.Mutation): 100 | class Arguments: 101 | input = CarInput() 102 | 103 | car = graphene.Field(CarType) 104 | ok = graphene.Boolean(default_value=False) 105 | 106 | @staticmethod 107 | def mutate(parent, info, input=None): 108 | persons_list = [] 109 | for person_id in input.persons_id: 110 | person_instance = Person.objects.get(id=person_id) 111 | persons_list.append(person_instance) 112 | 113 | car_instance = Car.objects.create(name=input.name, year=input.year) 114 | car_instance.person.set(persons_list) 115 | ok = True 116 | return CreateCar(car=car_instance, ok=ok) 117 | 118 | 119 | class Mutate(graphene.ObjectType): 120 | create_person = CreatePerson.Field() 121 | update_person = UpdatePerson.Field() 122 | delete_person = DeletePerson.Field() 123 | create_car = CreateCar.Field() 124 | -------------------------------------------------------------------------------- /home/templates/home/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block content %} 4 |

HOME

5 | {% endblock %} -------------------------------------------------------------------------------- /home/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /home/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | 5 | app_name = 'home' 6 | urlpatterns = [ 7 | path('', views.HomeView.as_view(), name='home'), 8 | ] -------------------------------------------------------------------------------- /home/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views import View 3 | 4 | 5 | class HomeView(View): 6 | def get(self, request): 7 | return render(request, 'home/home.html') 8 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'A.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Django 6 | 7 | 8 | 9 | {% include 'inc/navbar.html' %} 10 |
11 | {% include 'inc/messages.html' %} 12 | {% block content %} {% endblock %} 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /templates/inc/messages.html: -------------------------------------------------------------------------------- 1 | {% if messages %} 2 | {% for message in messages %} 3 |

{{ message }}

4 | {% endfor %} 5 | {% endif %} -------------------------------------------------------------------------------- /templates/inc/navbar.html: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------