###前提・実現したいこと
Pythonのdjangoを使いblogを作成しようとしています。下記のようにアプリケーションを作成しましたが、管理画面に行ってもアプリが反映されません。
・ホームディレクトリ内にmysiteというプロジェクトを作成
・command”django-admin.py startapp posts”によりmysiteディレクトリ内にpostsというアプリケーションを作成
・ソースコード修正
・command”python manage.py migrate”にて反映
・command”python manage.py runserver”にて起動
###発生している問題・エラーメッセージ
問題として、アプリケーションを作成したにも関わらず、下記の画像のように反映されないことです。
python manage.py migrateとすると下記のようになっています。問題の原因かもしれないのでアップしました。
Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: No migrations to apply.
###該当のソースコード
mysite/settings.py
※ 変更点のみ抜粋
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'posts', ]
mysite/urls.py
from django.conf.urls import url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), ]
posts/models.py
import os #追加 from django.db import models class Post(models.Model): title = models.CharField(max_length=200) content = models.TextField(max_length=10000) pub_date = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.title
posts/admin.py
from django.contrib import admin from .models import Post // Register your models here. // class PostAdmin(admin.ModelAdmin): // class Meta: // model = Post admin.site.register(Post, PostAdmin)
###補足情報(言語/FW/ツール等のバージョンなど)
・djangoのバージョン1.10.5
・Python 3.6.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/14 18:55