2016-08-08 3 views
0

enter image description hereDjangoの認証システムの作成」

私はジャンゴ1.7.11で働いています。私は既存のプロジェクトを持っており、私は管理パネル(私はスーパーユーザーを作成していない)を使ってみることに決めました。私は認証ページを開いたとき、私は見た:

enter image description here

は思考のテーブルに問題がある可能性があり、私はsqliteのデータベースと再実行、すべて削除することにしました:

$ python manage.py makemigrations app1 
Migrations for 'app1': 
    0001_initial.py: 
    - Create model Seller 

$ python manage.py migrate 
Operations to perform: 
    Synchronize unmigrated apps: crispy_forms 
    Apply all migrations: admin, contenttypes, auth, app1, sessions 
Synchronizing apps without migrations: 
    Creating tables... 
    Installing custom SQL... 
    Installing indexes... 
Running migrations: 
    Applying app1.0001_initial... FAKED 

$ python manage.py syncdb 
Operations to perform: 
    Synchronize unmigrated apps: crispy_forms 
    Apply all migrations: admin, contenttypes, auth, app1, sessions 
Synchronizing apps without migrations: 
    Creating tables... 
    Installing custom SQL... 
    Installing indexes... 
Running migrations: 
    No migrations to apply. 

You have installed Django's auth system, and don't have any superusers defined. 
Would you like to create one now? (yes/no): yes 
Created: 
Error: '' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format. 
Created: 

私はこの問題を解決することができますどのように?

編集:

APP1/models.py:

from django.db import models 
    # from django.contrib.auth.models import AbstractUser 



    class Seller(models.Model): 

     # Address 
     contact_name = models.CharField(max_length=50) 
     contact_address = models.CharField(max_length=50) 
     contact_email = models.CharField(max_length=50) 
     contact_phone = models.CharField(max_length=50) 
     ............ 
     created = models.DateTimeField(auto_now_add=True,unique=True) 

     REQUIRED_FIELDS = ('contact_name','contact_email','contact_address','contact_phone') 
     USERNAME_FIELD = 'created' 
+1

あなたはmodels1をapp1に投稿できますか? AUTH_USER_MODELはあなたが投稿したスクリーンショットの実際のモデルを指していません。カスタムユーザーモデルを使用しようとしていますか? – nkhumphreys

+0

上に追加... – user61629

答えて

1

あなたusernameフィールドがcreatedに設定されています。それをcontact_nameに変更してログインに「名前」を使用してください。

ただし、本当に必要がない限り、AbstractUserモデルを拡張してUSERNAME_FIELDを変更する必要があります。あなたは今それをやっている方法は、カスタムログイン意見などを書くためにあなたが必要となります。..

EDIT:

だけ再実行createsupseruser管理その後、settings.pyからラインAUTH_USER_MODELを削除し、デフォルトのユーザー・モデルを使用するにはコマンド。その後、adminログインページに戻り、ユーザー名とパスワードでログインします。

+0

nkhumphreys、これを見ていただきありがとうございます。私が本当に必要とするのは、管理者パネルを使用できるスーパーユーザーだけです。私はむしろ、Userモデルとは別のセラーモデルを持っています。この場合、最も基本的なユーザーモデルクラスを作成するために、私は何をする必要がありますか? – user61629

+0

私の編集@ user61629を参照してください – nkhumphreys

+0

ありがとう、行を削除した後、マイグレーションフォルダとsqllite dbを削除してからmakemigrations app1を実行し、syncdbを移行してSUを作成できました。 – user61629