· 7 years ago · Mar 19, 2018, 12:36 PM
1from tracker.models import ProxyItem
2
3Proxy = ProxyItem
4
5Proxy.address = '127.0.0.1:8000'
6Proxy.timeout = '0.003'
7Proxy.status = 'unchecked'
8
9Proxy.save()
10
11Traceback (most recent call last):
12 File "E:/apps/amz_service/tracker/modules/example.py", line 1, in <module>
13 from tracker.models import ProxyItem
14 File "E:appsamz_servicetrackermodels.py", line 6, in <module>
15 class ProxyItem(models.Model):
16 File "C:UsersRomanamz_envlibsite-packagesdjangodbmodelsbase.py", line 100, in __new__
17 app_config = apps.get_containing_app_config(module)
18 File "C:UsersRomanamz_envlibsite-packagesdjangoappsregistry.py", line 244, in get_containing_app_config
19 self.check_apps_ready()
20 File "C:UsersRomanamz_envlibsite-packagesdjangoappsregistry.py", line 127, in check_apps_ready
21 raise AppRegistryNotReady("Apps aren't loaded yet.")
22django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
23
24Process finished with exit code 1
25
26from django.db import models
27
28class ProxyItem(models.Model):
29 address = models.CharField(max_length=30)
30 timeout = models.IntegerField(default=0)
31 status = models.CharField(max_length=30, default='unchecked')
32 created_at = models.DateTimeField(auto_now_add=True)
33
34"""
35Django settings for amz_service project.
36
37Generated by 'django-admin startproject' using Django 1.10.6.
38
39For more information on this file, see
40https://docs.djangoproject.com/en/1.10/topics/settings/
41
42For the full list of settings and their values, see
43https://docs.djangoproject.com/en/1.10/ref/settings/
44"""
45
46# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
47import os
48
49BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
50FILE_DB_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/tracker/DB/'
51
52# Quick-start development settings - unsuitable for production
53# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
54
55# SECURITY WARNING: keep the secret key used in production secret!
56SECRET_KEY = '*4^99u4d!rtim)rk&6cjl)-ytszxxf8%p_n)s1!zbt@(=cx3q3'
57
58# SECURITY WARNING: don't run with debug turned on in production!
59DEBUG = True
60
61ALLOWED_HOSTS = [
62 '*'
63]
64
65
66# Application definition
67
68INSTALLED_APPS = [
69 'django.contrib.admin',
70 'django.contrib.auth',
71 'django.contrib.contenttypes',
72 'django.contrib.sessions',
73 'django.contrib.messages',
74 'django.contrib.staticfiles',
75 'django.contrib.sites',
76 'tracker.apps.TrackerConfig',
77]
78
79MIDDLEWARE = [
80 'django.middleware.security.SecurityMiddleware',
81 'django.contrib.sessions.middleware.SessionMiddleware',
82 'django.middleware.common.CommonMiddleware',
83 'django.middleware.csrf.CsrfViewMiddleware',
84 'django.contrib.auth.middleware.AuthenticationMiddleware',
85 'django.contrib.messages.middleware.MessageMiddleware',
86 'django.middleware.clickjacking.XFrameOptionsMiddleware',
87]
88
89ROOT_URLCONF = 'amz_service.urls'
90
91TEMPLATES = [
92 {
93 'BACKEND': 'django.template.backends.django.DjangoTemplates',
94 'DIRS': [os.path.join(BASE_DIR, 'templates')]
95 ,
96 'APP_DIRS': True,
97 'OPTIONS': {
98 'context_processors': [
99 'django.template.context_processors.debug',
100 'django.template.context_processors.request',
101 'django.contrib.auth.context_processors.auth',
102 'django.contrib.messages.context_processors.messages',
103 ],
104 },
105 },
106]
107
108WSGI_APPLICATION = 'amz_service.wsgi.application'
109
110
111# Database
112# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
113
114DATABASES = {
115 'default': {
116 'ENGINE': 'django.db.backends.postgresql_psycopg2',
117 'NAME': 'amz_service',
118 'USER': 'amz_service',
119 'PASSWORD': 'root',
120 'HOST': 'localhost',
121 'PORT': '5432',
122 },
123}
124
125# DATABASES = {
126# 'default': {
127# 'ENGINE': 'django.db.backends.sqlite3',
128# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
129# }
130# }
131
132
133# Password validation
134# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
135
136AUTH_PASSWORD_VALIDATORS = [
137 {
138 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
139 },
140 {
141 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
142 },
143 {
144 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
145 },
146 {
147 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
148 },
149]
150
151
152# Internationalization
153# https://docs.djangoproject.com/en/1.10/topics/i18n/
154
155LANGUAGE_CODE = 'en-us'
156
157USE_TZ = True
158TIME_ZONE = 'Europe/Kiev'
159
160USE_I18N = True
161
162USE_L10N = True
163
164
165# Static files (CSS, JavaScript, Images)
166# https://docs.djangoproject.com/en/1.10/howto/static-files/
167
168STATIC_URL = '/resources/'
169STATIC_ROOT = os.path.join(BASE_DIR, "static/")
170PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
171
172"""
173WSGI config for amz_service project.
174
175It exposes the WSGI callable as a module-level variable named ``application``.
176
177For more information on this file, see
178https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
179"""
180
181import os
182
183from django.core.wsgi import get_wsgi_application
184
185os.environ.setdefault("DJANGO_SETTINGS_MODULE", "amz_service.settings")
186
187application = get_wsgi_application()
188
189from django.apps import AppConfig
190
191
192class TrackerConfig(AppConfig):
193 name = 'tracker'