LoginSignup
3
1

More than 5 years have passed since last update.

VisualStudioでDjangoアプリの作成と管理アプリの有効化を行う

Last updated at Posted at 2018-07-22

VisualStdioでDjangoの新しいアプリを作成し、管理者アプリを有効化する

VisualStudioでDjangoWebAppを作成

ファイル > 新規プロジェクト > 作成

pythonタブからDjango Webアプリを作成

Adminアプリを有効化する

url.pyの最後のほうにあるadminアプリのコメントアウトを削除して、

url.py
    # Uncomment the admin/doc line below to enable admin documentation:
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),

import部分にadminを追加

url.py
from django.contrib import admin

管理者アプリのユーザを作成する

地味にはまったのが、管理コンソールでmanage.py createuserとかしても動かないこと。
(やり方知っている人がいたら教えてください...。)
基本的にmigrateとかもプロジェクト以下のボタンをポチポチしてできる。

プロジェクト > Djangoでスーパーユーザーを作成する を選択

コンソールでユーザ名、メールアドレス、パスワードを設定

実行

Webサーバーを実行(緑の矢印ボタンを押すだけ)
http://localhost:xxxx/admin/にアクセスしてログインできたら完了

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1