maxg203 / DRF-Angular-To-Do-List

Source code for the To Do List app in my free YouTube series.
https://www.youtube.com/playlist?list=PLw02n0FEB3E0smsGO7EcnSqR-PCAWruJC
4 stars 5 forks source link

Introduction to Angular 1.6.x (JavaScript Front End) | Part 5 #1

Open stevenduong1983 opened 6 years ago

stevenduong1983 commented 6 years ago

Hi Max,

Could you please help me on this error. Thanks.

---settings.py

""" Django settings for todo project.

Generated by 'django-admin startproject' using Django 1.11.2.

For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """

import os

Build paths inside the project like this: os.path.join(BASE_DIR, ...)

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(file)))

Quick-start development settings - unsuitable for production

See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = '3i2t=3(xswe51jksl7c-auw7-)24^08lzuif(-j4dypc9x60bk'

SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = []

Application definition

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ]

MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ]

ROOT_URLCONF = 'todo.urls'

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ]

WSGI_APPLICATION = 'todo.wsgi.application'

Database

https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'todo', 'USER':'root', 'PASSWORD':'' } }

Password validation

https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ]

Internationalization

https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

Static files (CSS, JavaScript, Images)

https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/',

STATICFILES_DIRS = { 'static' }

index.html <!DOCTYPE html>

To do list {% load static %}

To Do List



todo.js

var app=angular.module('toDo',[]);

app.controller('toDoController',function ($scope) { $scope.todoList=[{todoText:'Finish the app'}]; $scope.todoAdd = function () { $scope.todoList.push({todoText:$scope.todoText}); $scope.todoInput=''; }; })

Performing system checks...

Unhandled exception in thread started by <function check_errors..wrapper at 0x03E9FBB8> Traceback (most recent call last): File "C:\sandex\lib\site-packages\django\utils\autoreload.py", line 227, in wr apper fn(*args, kwargs) File "C:\sandex\lib\site-packages\django\core\management\commands\runserver.py ", line 125, in inner_run self.check(display_num_errors=True) File "C:\sandex\lib\site-packages\django\core\management\base.py", line 359, i n check include_deployment_checks=include_deployment_checks, File "C:\sandex\lib\site-packages\django\core\management\base.py", line 346, i n _run_checks return checks.run_checks(kwargs) File "C:\sandex\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\sandex\lib\site-packages\django\core\checks\urls.py", line 104, in ch eck_url_settings if value and not value.endswith('/'): AttributeError: 'tuple' object has no attribute 'endswith' Performing system checks...

Unhandled exception in thread started by <function check_errors..wrapper at 0x039FFBB8> Traceback (most recent call last): File "C:\sandex\lib\site-packages\django\utils\autoreload.py", line 227, in wr apper fn(*args, kwargs) File "C:\sandex\lib\site-packages\django\core\management\commands\runserver.py ", line 125, in inner_run self.check(display_num_errors=True) File "C:\sandex\lib\site-packages\django\core\management\base.py", line 359, i n check include_deployment_checks=include_deployment_checks, File "C:\sandex\lib\site-packages\django\core\management\base.py", line 346, i n _run_checks return checks.run_checks(kwargs) File "C:\sandex\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\sandex\lib\site-packages\django\core\checks\urls.py", line 104, in ch eck_url_settings if value and not value.endswith('/'): AttributeError: 'tuple' object has no attribute 'endswith'