Django user shows 2 users rows sql table auth_user has over 3000 rows

19 views
Skip to first unread message

NoviceSortOf

unread,
Dec 21, 2016, 3:46:20 PM12/21/16
to Django users

From the command line in Python

>>from books.models import user 
>>custs = list(rusers.objects.all())
>>print custs
>>[<user: TEST145>, <user: TEST1459>]

From SQL
SELECT *  FROM auth_user WHERE username LIKE '%TEST%'
-- None found.

auth_user has been vacuumed, and reindexed during the tests.

- Where and in what schema are these mysterious 2 user rows being stored?

Any clues welcome.

Models.py excerpt follows.

------------------------------------------------------------------------------------------------------------------------------------

from django.db import models
from django.contrib.auth.models import User
from django.core import validators
from django.utils.http import urlquote
from django.utils.translation import ugettext_lazy as _
from django.core.mail import send_mail
import re
# from userprofile.models import BaseProfile
from django.utils.translation import ugettext as _
from django.conf import settings
import datetime
from django.utils import timezone
from django.contrib.auth.models import BaseUserManager
from django.contrib.auth.models import UserManager
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin


class user(AbstractBaseUser, PermissionsMixin):
    """
    Custom user structure
   
    """
    username = models.CharField(_('username'), max_length=30, unique=True,
        help_text=_('Required. 30 characters or fewer. Letters, numbers and '
                    '@/./+/-/_ characters'),
        validators=[
            validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')
        ])
    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    email = models.EmailField(_('email address'), blank=True)
    is_staff = models.BooleanField(_('staff status'), default=False,
        help_text=_('Designates whether the user can log into this admin '
                    'site.'))
    is_active = models.BooleanField(_('active'), default=True,
        help_text=_('Designates whether this user should be treated as '
                    'active. Unselect this instead of deleting accounts.'))
    date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
    objects = UserManager()
    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['email']

NoviceSortOf

unread,
Dec 21, 2016, 4:59:51 PM12/21/16
to Django users
To answer my own question on doing a psql dump of the data base found the 2 records 
in books_user  auth_user --now that the custom user has been entered on models. 
Should of known from the line -- import from books.models import user 
Reply all
Reply to author
Forward
0 new messages