user1592380
user1592380

Reputation: 36307

django auth system 'created'

enter image description here

I'm working with django 1.7.11. I have a preexisting project and I've decided to try to use the built in admin panel (I have not created a superuser). When I opened the auth page I saw :

enter image description here

Thinking there may be a problem with the tables I decided to delete the sqlite database and rerun everything:

$ 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:

How can I fix this?

edit:

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'

Upvotes: 0

Views: 63

Answers (1)

nkhumphreys
nkhumphreys

Reputation: 996

Your username field is set to created. Change it to contact_name to use a "name" to log in.

However!... You should probably extend the AbstractUser model and not change the USERNAME_FIELD unless you really have to. The way you are doing it now will require you to write custom login views etc..

EDIT:

To use the default user model just delete the line AUTH_USER_MODEL from settings.py then re-run the createsupseruser management command. Then go back to the admin login page and login with the username and password.

Upvotes: 1

Related Questions