djangoでエラーが出ます。
$ python3 manage.py runserver raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e django.core.exceptions.ImproperlyConfigured: The included URLconf 'app.urls' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.
urls.py
1from django.contrib import admin 2from django.urls import path,include # include を追記 3#from petino.urls import router as sample_router 4 5urlpatterns = [ 6 path(r'^admin/', admin.site.urls), 7 # blog.urlsをincludeする 8 path(r'^api/', include("app.urls")), 9]
settings.py
1import os 2import dj_database_url #追加 3 4BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 5 6DEBUG = False #Trueから変更 7 8ALLOWED_HOSTS = ['127.0.0.1', '.herokuapp.com'] #追加 9 10INSTALLED_APPS = [ 11 'django.contrib.admin', 12 'django.contrib.auth', 13 'django.contrib.contenttypes', 14 'django.contrib.sessions', 15 'django.contrib.messages', 16 'django.contrib.staticfiles', 17 'app', #アプリ名 18] 19 20MIDDLEWARE = [ 21 'django.middleware.security.SecurityMiddleware', 22 'django.contrib.sessions.middleware.SessionMiddleware', 23 'django.middleware.common.CommonMiddleware', 24 'django.middleware.csrf.CsrfViewMiddleware', 25 'django.contrib.auth.middleware.AuthenticationMiddleware', 26 'django.contrib.messages.middleware.MessageMiddleware', 27 'django.middleware.clickjacking.XFrameOptionsMiddleware', 28 'whitenoise.middleware.WhiteNoiseMiddleware', #追加 29] 30 31ROOT_URLCONF = 'app.urls' #アプリ名 32 33TEMPLATES = [ 34 { 35 'BACKEND': 'django.template.backends.django.DjangoTemplates', 36 'DIRS': [], 37 'APP_DIRS': True, 38 'OPTIONS': { 39 'context_processors': [ 40 'django.template.context_processors.debug', 41 'django.template.context_processors.request', 42 'django.contrib.auth.context_processors.auth', 43 'django.contrib.messages.context_processors.messages', 44 ], 45 }, 46 }, 47] 48 49WSGI_APPLICATION = 'app.wsgi.application' #ご自身のアプリ名 50 51DATABASES = { 52 'default': { 53 'ENGINE': 'django.db.backends.postgresql_psycopg2', #sqlite3から変更 54 'NAME': 'name', 55 'USER': 'user', 56 'PASSWORD': '', 57 'HOST': 'localhost', 58 'PORT': '', 59 } 60} 61 62AUTH_PASSWORD_VALIDATORS = [ 63 { 64 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 65 }, 66 { 67 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 68 }, 69 { 70 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 71 }, 72 { 73 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 74 }, 75] 76 77LANGUAGE_CODE = 'ja' 78 79TIME_ZONE = 'Asia/Tokyo' 80 81USE_I18N = True 82 83USE_L10N = True 84 85USE_TZ = True 86 87STATIC_URL = '/static/' 88 89STATICFILES_DIRS =( 90 os.path.join(BASE_DIR, 'static') 91) 92 93STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') #追加 94 95#追加 96try: 97 from .local_settings import * 98except ImportError: 99 pass 100 101if not DEBUG: 102 SECRET_KEY = os.environ['SECRET_KEY'] 103 import django_heroku 104 django_heroku.settings(locals()) 105 106db_from_env = dj_database_url.config(conn_max_age=600, ssl_require=True) 107DATABASES['default'].update(db_from_env) 108
app/urls.py
1from rest_framework import routers 2from .views import UserViewSet, Post_officeViewSet,Good_tableViewSet,Follow_tableViewSet 3 4app_name= "app" 5router = routers.DefaultRouter() 6router.register(r'users/', UserViewSet) 7router.register(r'post_office/', Post_officeViewSet) 8router.register(r'good_table', Good_tableViewSet) 9router.register(r'follow_table', Follow_tableViewSet) 10#snsを製作中です。
tree
1 2├── config 3│ ├── __init__.py 4│ ├── __pycache__ 5│ ├── local_settings.py 6│ ├── settings.py 7│ ├── urls.py 8│ └── wsgi.py 9├── manage.py 10└── app 11 ├── __init__.py 12 ├── __pycache__ 13 ├── admin.py 14 ├── apps.py 15 ├── migrations 16 │ └── __init__.py 17 ├── models.py 18 ├── serializer.py 19 ├── tests.py 20 ├── urls.py 21 └── views.py 22
あなたの回答
tips
プレビュー