· 8 years ago · Dec 27, 2017, 02:22 AM
1Traceback (most recent call last):
2File "C:/Users/Pritee/djangogirls/blog/models.py", line 6, in <module>
3class Post(models.Model):
4File "C:UsersPriteedjangogirlsmyvenvlibsite-
5packagesdjangodbmodelsbase.py", line 100, in __new__
6app_config = apps.get_containing_app_config(module)
7File "C:UsersPriteedjangogirlsmyvenvlibsite-
8packagesdjangoappsregistry.py", line 244, in get_containing_app_config
9self.check_apps_ready()
10File "C:UsersPriteedjangogirlsmyvenvlibsite-
11packagesdjangoappsregistry.py", line 127, in check_apps_ready
12raise AppRegistryNotReady("Apps aren't loaded yet.")
13django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
14
15from django.db import models
16
17from django.utils import timezone
18
19
20class Post(models.Model):
21 author = models.ForeignKey('auth.User',on_delete=models.CASCADE)
22 title = models.CharField(max_length=200)
23 text = models.TextField()
24 created_date = models.DateTimeField(
25 default=timezone.now)
26published_date = models.DateTimeField(
27 blank=True, null=True)
28
29def publish(self):
30 self.published_date = timezone.now()
31 self.save()
32
33def __str__(self):
34 return self.title
35
36import os
37
38# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
39BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
40
41
42# Quick-start development settings - unsuitable for production
43# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
44
45# SECURITY WARNING: keep the secret key used in production secret!
46SECRET_KEY = 'iua)_567ww!*c9#dhg#f&u4ft$(47!cz@98!$ro=^+u!+t'
47
48# SECURITY WARNING: don't run with debug turned on in production!
49DEBUG = True
50
51ALLOWED_HOSTS = ['127.0.0.1']
52
53
54# Application definition
55
56INSTALLED_APPS = [
57'django.contrib.admin',
58'django.contrib.auth',
59'django.contrib.contenttypes',
60'django.contrib.sessions',
61'django.contrib.messages',
62'django.contrib.staticfiles',
63'blog'
64]
65
66MIDDLEWARE = [
67'django.middleware.security.SecurityMiddleware',
68'django.contrib.sessions.middleware.SessionMiddleware',
69'django.middleware.common.CommonMiddleware',
70'django.middleware.csrf.CsrfViewMiddleware',
71'django.contrib.auth.middleware.AuthenticationMiddleware',
72'django.contrib.messages.middleware.MessageMiddleware',
73'django.middleware.clickjacking.XFrameOptionsMiddleware',
74]
75
76ROOT_URLCONF = 'mysite.urls'
77
78TEMPLATES = [
79{
80 'BACKEND': 'django.template.backends.django.DjangoTemplates',
81 'DIRS': [],
82 'APP_DIRS': True,
83 'OPTIONS': {
84 'context_processors': [
85 'django.template.context_processors.debug',
86 'django.template.context_processors.request',
87 'django.contrib.auth.context_processors.auth',
88 'django.contrib.messages.context_processors.messages',
89 ],
90 },
91},
92]
93
94WSGI_APPLICATION = 'mysite.wsgi.application'
95
96
97# Database
98# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
99
100DATABASES = {
101'default': {
102 'ENGINE': 'django.db.backends.sqlite3',
103 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
104 }
105}
106
107
108# Password validation
109# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-
110validators
111
112AUTH_PASSWORD_VALIDATORS = [
113{
114 'NAME':
115'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
116},
117{
118 'NAME':
119'django.contrib.auth.password_validation.MinimumLengthValidator',
120},
121{
122 'NAME':
123'django.contrib.auth.password_validation.CommonPasswordValidator',
124},
125{
126 'NAME':
127'django.contrib.auth.password_validation.NumericPasswordValidator',
128},
129]
130
131
132# Internationalization
133# https://docs.djangoproject.com/en/2.0/topics/i18n/
134
135LANGUAGE_CODE = 'en-us'
136
137TIME_ZONE = 'UTC'
138
139USE_I18N = True
140
141USE_L10N = True
142
143USE_TZ = True
144
145
146# Static files (CSS, JavaScript, Images)
147# https://docs.djangoproject.com/en/2.0/howto/static-files/
148
149STATIC_URL = '/static/'
150STATIC_ROOT = os.path.join(BASE_DIR, 'static')