├── .gitignore ├── README.md ├── user_models_abstractBaseUser ├── abstract_base_user_sample │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── 0002_customuser_is_staff.py │ │ ├── 0003_auto_20170529_1735.py │ │ └── __init__.py │ ├── models.py │ ├── templates │ │ └── abstract_base_user_sample │ │ │ └── home.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── manage.py ├── requirements.txt └── user_models_abstractBaseUser │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── user_models_abstractUser ├── abstract_user_sample │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── models.py │ ├── templates │ │ └── abstract_user_sample │ │ │ └── home.html │ ├── tests.py │ ├── urls.py │ └── views.py ├── db.sqlite3 ├── manage.py ├── requirements.txt └── user_models_abstractUser │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── user_models_oneToOne ├── db.sqlite3 ├── manage.py ├── one_to_one_sample ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── migrations │ └── __init__.py ├── models.py ├── templates │ └── one_to_one_sample │ │ └── home.html ├── tests.py ├── urls.py └── views.py ├── requirements.txt └── user_models_oneToOne ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py /.gitignore: -------------------------------------------------------------------------------- 1 | du 2 | *secret.sh 3 | *.pyc 4 | *migrations 5 | .DS_Store 6 | db.sqlite3 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # django-user-model-options 2 | Repo with in-depth coverage of high level concepts from a poster session I did at PyCon 2017 in Portland, OR, May 21, 2017. 3 | 4 | An in-depth discussion of each of the three options I presented for customizing the Django User model can be found in [this blog post](https://medium.com/agatha-codes/options-objects-customizing-the-django-user-model-6d42b3e971a4) on [_Agatha_](https://medium.com/agatha-codes), a blog I started to share some of the problem solving I've had to do when working on my software projects. 5 | 6 | All of these projects use Django 1.11, Python 3.5.2 and the default SQLite3 database. 7 | 8 | Each project in this repo covers one of the three options and stands on its own. To run a project: 9 | 10 | - Navigate to the relevant repo and clone it 11 | 12 | - Create a Python3 virtual environment `python3 -m venv myvenv` 13 | 14 | - Install the requirements.txt file `pip install -r requirements.txt` 15 | 16 | - Create a superuser `python manage.py createsuperuser` and complete the prompts 17 | 18 | - Start the server with `python manage.py runserver` 19 | 20 | - To try the form, navigate to `localhost:8000` in your browser 21 | 22 | - To try the admin interface, navigate to `localhost:8000/admin` in your browser and sign in with the credentials you entered when you ran the `createsuperuser` command 23 | 24 | If you have any comments, questions or problems with the examples, please create an issue in this repo. 25 | 26 | Thanks for visiting!! 27 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractBaseUser/abstract_base_user_sample/__init__.py -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import CustomUser 3 | 4 | admin.site.register(CustomUser) 5 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AbstractBaseUserSampleConfig(AppConfig): 5 | name = 'abstract_base_user_sample' 6 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.forms import UserCreationForm 3 | from .models import CustomUser 4 | 5 | class CustomUserForm(UserCreationForm): 6 | class Meta(UserCreationForm.Meta): 7 | model = CustomUser 8 | fields = ('email', 'zip_code') 9 | error_css_class = 'error' 10 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.1 on 2017-05-28 17:57 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | ] 14 | 15 | operations = [ 16 | migrations.CreateModel( 17 | name='CustomUser', 18 | fields=[ 19 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 20 | ('password', models.CharField(max_length=128, verbose_name='password')), 21 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 22 | ('email', models.EmailField(max_length=254, unique=True)), 23 | ('zip_code', models.CharField(max_length=6)), 24 | ('name', models.CharField(max_length=30)), 25 | ], 26 | options={ 27 | 'abstract': False, 28 | }, 29 | ), 30 | ] 31 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/migrations/0002_customuser_is_staff.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.1 on 2017-05-28 19:01 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('abstract_base_user_sample', '0001_initial'), 12 | ] 13 | 14 | operations = [ 15 | migrations.AddField( 16 | model_name='customuser', 17 | name='is_staff', 18 | field=models.BooleanField(default=False), 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/migrations/0003_auto_20170529_1735.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by Django 1.11.1 on 2017-05-29 17:35 3 | from __future__ import unicode_literals 4 | 5 | from django.db import migrations, models 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | dependencies = [ 11 | ('auth', '0008_alter_user_username_max_length'), 12 | ('abstract_base_user_sample', '0002_customuser_is_staff'), 13 | ] 14 | 15 | operations = [ 16 | migrations.AddField( 17 | model_name='customuser', 18 | name='groups', 19 | field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups'), 20 | ), 21 | migrations.AddField( 22 | model_name='customuser', 23 | name='is_superuser', 24 | field=models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status'), 25 | ), 26 | migrations.AddField( 27 | model_name='customuser', 28 | name='user_permissions', 29 | field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'), 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractBaseUser/abstract_base_user_sample/migrations/__init__.py -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import PermissionsMixin, AbstractBaseUser, BaseUserManager 3 | 4 | class CustomAccountManager(BaseUserManager): 5 | def create_user(self, email, zip_code, password): 6 | user = self.model(email=email, zip_code=zip_code, password=password) 7 | user.set_password(password) 8 | user.is_staff = False 9 | user.is_superuser = False 10 | user.save(using=self._db) 11 | return user 12 | 13 | def create_superuser(self, email, zip_code, password): 14 | user = self.create_user(email=email, zip_code=zip_code, password=password) 15 | user.is_active = True 16 | user.is_staff = True 17 | user.is_superuser = True 18 | user.save(using=self._db) 19 | return user 20 | 21 | def get_by_natural_key(self, email_): 22 | print(email_) 23 | return self.get(email=email_) 24 | 25 | 26 | class CustomUser(AbstractBaseUser, PermissionsMixin): 27 | """ 28 | Here we are subclassing the Django AbstractBaseUser, which comes with only 29 | 3 fields: 30 | 1 - password 31 | 2 - last_login 32 | 3 - is_active 33 | Note than all fields would be required unless specified otherwise, with 34 | `required=False` in the parentheses. 35 | 36 | The PermissionsMixin is a model that helps you implement permission settings 37 | as-is or modified to your requirements. 38 | More info: https://goo.gl/YNL2ax 39 | """ 40 | email = models.EmailField(unique=True) 41 | zip_code = models.CharField(max_length=6) 42 | name = models.CharField(max_length=30) 43 | is_staff = models.BooleanField(default=False) 44 | REQUIRED_FIELDS = ['zip_code'] 45 | USERNAME_FIELD = 'email' 46 | 47 | objects = CustomAccountManager() 48 | 49 | def get_short_name(self): 50 | return self.email 51 | 52 | def natural_key(self): 53 | return self.email 54 | 55 | def __str__(self): 56 | return self.email 57 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/templates/abstract_base_user_sample/home.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |This is an example of a signup form with custom fields based on a model that 7 | subclasses the AbstractBaseUser model in Django.
8 | 9 |Aside from a couple of fields Django always retains for any user (is_active, 10 | last_login and password), this option enables you to restrict the fields to whatever 11 | you want.
12 | 13 | 22 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url, include 2 | from . import views 3 | 4 | print(views) 5 | 6 | urlpatterns = [ 7 | url(r'^$', views.home, name='home') 8 | ] 9 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/abstract_base_user_sample/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from .forms import CustomUserForm 4 | 5 | 6 | def home(request): 7 | if request.method == 'POST': 8 | form = CustomUserForm(request.POST) 9 | if form.is_valid(): 10 | form.save() 11 | return HttpResponse("User was created successfully.") 12 | else: 13 | return HttpResponse("There was an error.") 14 | else: 15 | form = CustomUserForm() 16 | 17 | return render(request, 'abstract_base_user_sample/home.html', {'form': form}) 18 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_abstractBaseUser.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.9 2 | anaconda-clean==1.0 3 | anaconda-client==1.6.0 4 | anaconda-navigator==1.3.2 5 | appnope==0.1.0 6 | appscript==1.0.1 7 | argcomplete==1.0.0 8 | astroid==1.4.9 9 | astropy==1.3 10 | Babel==2.3.4 11 | backports.shutil-get-terminal-size==1.0.0 12 | beautifulsoup4==4.5.3 13 | bitarray==0.8.1 14 | blaze==0.10.1 15 | bokeh==0.12.4 16 | boto==2.45.0 17 | botocore==1.4.93 18 | Bottleneck==1.2.0 19 | cffi==1.9.1 20 | chardet==2.3.0 21 | chest==0.2.3 22 | click==6.7 23 | cloudpickle==0.2.2 24 | clyent==1.2.2 25 | colorama==0.3.7 26 | conda==4.3.8 27 | conda-build==2.1.2 28 | conda-verify==2.0.0 29 | configobj==5.0.6 30 | contextlib2==0.5.4 31 | cryptography==1.7.1 32 | cycler==0.10.0 33 | Cython==0.25.2 34 | cytoolz==0.8.2 35 | dask==0.13.0 36 | datashape==0.5.4 37 | decorator==4.0.11 38 | dill==0.2.5 39 | Django==1.11.1 40 | docutils==0.13.1 41 | dynd==0.7.3.dev1 42 | et-xmlfile==1.0.1 43 | fastcache==1.0.2 44 | filelock==2.0.7 45 | Flask==0.12 46 | Flask-Cors==3.0.2 47 | geopy==1.11.0 48 | gevent==1.2.1 49 | greenlet==0.4.11 50 | h5py==2.6.0 51 | HeapDict==1.0.0 52 | idna==2.2 53 | imagesize==0.7.1 54 | ipykernel==4.5.2 55 | ipython==5.1.0 56 | ipython-genutils==0.1.0 57 | ipywidgets==5.2.2 58 | isort==4.2.5 59 | itsdangerous==0.24 60 | jdcal==1.3 61 | jedi==0.9.0 62 | Jinja2==2.9.4 63 | jmespath==0.9.1 64 | jsonschema==2.5.1 65 | jupyter==1.0.0 66 | jupyter-client==4.4.0 67 | jupyter-console==5.0.0 68 | jupyter-core==4.2.1 69 | lazy-object-proxy==1.2.2 70 | llvmlite==0.15.0 71 | locket==0.2.0 72 | lxml==3.7.2 73 | MarkupSafe==0.23 74 | matplotlib==2.0.0 75 | mistune==0.7.3 76 | mpmath==0.19 77 | multipledispatch==0.4.9 78 | nb-anacondacloud==1.2.0 79 | nb-conda==2.0.0 80 | nb-conda-kernels==2.0.0 81 | nbconvert==4.2.0 82 | nbformat==4.2.0 83 | nbpresent==3.0.2 84 | networkx==1.11 85 | nltk==3.2.2 86 | node==0.9.18.1 87 | nose==1.3.7 88 | notebook==4.3.1 89 | numba==0.30.1 90 | numexpr==2.6.1 91 | numpy==1.11.3 92 | numpydoc==0.6.0 93 | odict==1.5.2 94 | odo==0.5.0 95 | openpyxl==2.4.1 96 | optional-django==0.1.0 97 | pandas==0.19.2 98 | partd==0.3.7 99 | pathlib2==2.2.0 100 | patsy==0.4.1 101 | pep8==1.7.0 102 | pexpect==4.2.1 103 | pickleshare==0.7.4 104 | Pillow==4.0.0 105 | pkginfo==1.4.1 106 | pluggy==0.4.0 107 | plumber==1.3.1 108 | ply==3.9 109 | prompt-toolkit==1.0.9 110 | psutil==5.0.1 111 | ptyprocess==0.5.1 112 | py==1.4.32 113 | pyasn1==0.1.9 114 | pycosat==0.6.1 115 | pycparser==2.17 116 | pycrypto==2.6.1 117 | pycurl==7.43.0 118 | pyflakes==1.5.0 119 | Pygments==2.1.3 120 | pylint==1.6.4 121 | pyOpenSSL==16.2.0 122 | pyparsing==2.1.4 123 | pytest==3.0.5 124 | python-dateutil==2.6.0 125 | python-http-client==2.2.1 126 | pytz==2016.10 127 | PyYAML==3.12 128 | pyzmq==16.0.2 129 | QtAwesome==0.4.3 130 | qtconsole==4.2.1 131 | QtPy==1.2.1 132 | redis==2.10.5 133 | requests==2.13.0 134 | rope-py3k==0.9.4.post1 135 | s3transfer==0.1.10 136 | scikit-image==0.12.3 137 | scikit-learn==0.18.1 138 | scipy==0.18.1 139 | sendgrid==3.6.3 140 | Shapely==1.5.17.post1 141 | simplegeneric==0.8.1 142 | singledispatch==3.4.0.3 143 | six==1.10.0 144 | snowballstemmer==1.2.1 145 | sockjs-tornado==1.0.3 146 | Sphinx==1.5.1 147 | spyder==3.1.2 148 | SQLAlchemy==1.1.5 149 | statsmodels==0.6.1 150 | sympy==1.0 151 | tables==3.3.0 152 | terminado==0.6 153 | toolz==0.8.2 154 | tornado==4.4.2 155 | traitlets==4.3.1 156 | unicodecsv==0.14.1 157 | virtualenv==15.1.0 158 | wcwidth==0.1.7 159 | Werkzeug==0.11.15 160 | widgetsnbextension==1.2.6 161 | wrapt==1.10.8 162 | xlrd==1.0.0 163 | XlsxWriter==0.9.6 164 | xlwings==0.10.2 165 | xlwt==1.2.0 166 | zope.component==4.3.0 167 | zope.deprecation==4.2.0 168 | zope.event==4.2.0 169 | zope.interface==4.3.3 170 | zope.lifecycleevent==4.1.0 171 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/user_models_abstractBaseUser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractBaseUser/user_models_abstractBaseUser/__init__.py -------------------------------------------------------------------------------- /user_models_abstractBaseUser/user_models_abstractBaseUser/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '') 6 | 7 | # SECURITY WARNING: don't run with debug turned on in production! 8 | DEBUG = True 9 | 10 | ALLOWED_HOSTS = [] 11 | 12 | INSTALLED_APPS = [ 13 | 'abstract_base_user_sample', 14 | 'django.contrib.admin', 15 | 'django.contrib.auth', 16 | 'django.contrib.contenttypes', 17 | 'django.contrib.sessions', 18 | 'django.contrib.messages', 19 | 'django.contrib.staticfiles', 20 | 21 | ] 22 | 23 | MIDDLEWARE = [ 24 | 'django.middleware.security.SecurityMiddleware', 25 | 'django.contrib.sessions.middleware.SessionMiddleware', 26 | 'django.middleware.common.CommonMiddleware', 27 | 'django.middleware.csrf.CsrfViewMiddleware', 28 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 29 | 'django.contrib.messages.middleware.MessageMiddleware', 30 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 31 | ] 32 | 33 | ROOT_URLCONF = 'user_models_abstractBaseUser.urls' 34 | 35 | TEMPLATES = [ 36 | { 37 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 38 | 'DIRS': [], 39 | 'APP_DIRS': True, 40 | 'OPTIONS': { 41 | 'context_processors': [ 42 | 'django.template.context_processors.debug', 43 | 'django.template.context_processors.request', 44 | 'django.contrib.auth.context_processors.auth', 45 | 'django.contrib.messages.context_processors.messages', 46 | ], 47 | }, 48 | }, 49 | ] 50 | 51 | WSGI_APPLICATION = 'user_models_abstractBaseUser.wsgi.application' 52 | 53 | DATABASES = { 54 | 'default': { 55 | 'ENGINE': 'django.db.backends.sqlite3', 56 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 57 | } 58 | } 59 | 60 | AUTH_USER_MODEL = 'abstract_base_user_sample.CustomUser' 61 | 62 | AUTH_PASSWORD_VALIDATORS = [ 63 | { 64 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 65 | }, 66 | { 67 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 68 | }, 69 | { 70 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 71 | }, 72 | { 73 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 74 | }, 75 | ] 76 | 77 | 78 | LANGUAGE_CODE = 'en-us' 79 | 80 | TIME_ZONE = 'UTC' 81 | 82 | USE_I18N = True 83 | 84 | USE_L10N = True 85 | 86 | USE_TZ = True 87 | 88 | 89 | STATIC_URL = '/static/' 90 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/user_models_abstractBaseUser/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | from django.contrib import admin 3 | 4 | urlpatterns = [ 5 | url(r'^admin/', admin.site.urls), 6 | url(r'', include('abstract_base_user_sample.urls')), 7 | ] 8 | -------------------------------------------------------------------------------- /user_models_abstractBaseUser/user_models_abstractBaseUser/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for user_models_abstractBaseUser project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_abstractBaseUser.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractUser/abstract_user_sample/__init__.py -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import CustomUser 3 | 4 | admin.site.register(CustomUser) 5 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AbstractUserSampleConfig(AppConfig): 5 | name = 'abstract_user_sample' 6 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.forms import UserCreationForm 3 | from .models import CustomUser 4 | 5 | class CustomUserForm(UserCreationForm): 6 | class Meta(UserCreationForm.Meta): 7 | model = CustomUser 8 | fields = ('email', 'zip_code') 9 | error_css_class = 'error' 10 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractUser 3 | 4 | class CustomUser(AbstractUser): 5 | email = models.EmailField(unique=True) 6 | zip_code = models.CharField(max_length=6) 7 | username = models.CharField(blank=True, null=True, max_length=150) 8 | REQUIRED_FIELDS = ['zip_code', 'username'] 9 | USERNAME_FIELD = 'email' 10 | 11 | def __str__(self): 12 | return self.email 13 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/templates/abstract_user_sample/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |This is an example of a signup form with custom fields based on a model that 8 | subclasses the AbstractUser model in Django.
9 | 10 |The default Django fields are still present in the model and the database, but 11 | not shown in the form.
12 | 13 | 22 | 23 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from . import views 3 | 4 | urlpatterns = [ 5 | url(r'^$', views.home, name='home'), 6 | ] 7 | -------------------------------------------------------------------------------- /user_models_abstractUser/abstract_user_sample/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from .forms import CustomUserForm 4 | 5 | def home(request): 6 | if request.method == 'POST': 7 | form = CustomUserForm(request.POST) 8 | print(form) 9 | if form.is_valid(): 10 | form.save() 11 | return HttpResponse("User was created successfully.") 12 | else: 13 | return HttpResponse("There was an error.") 14 | else: 15 | form = CustomUserForm() 16 | return render(request, 'abstract_user_sample/home.html', {'form': form}) 17 | -------------------------------------------------------------------------------- /user_models_abstractUser/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractUser/db.sqlite3 -------------------------------------------------------------------------------- /user_models_abstractUser/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_abstractUser.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /user_models_abstractUser/requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.9 2 | anaconda-clean==1.0 3 | anaconda-client==1.6.0 4 | anaconda-navigator==1.3.2 5 | appnope==0.1.0 6 | appscript==1.0.1 7 | argcomplete==1.0.0 8 | astroid==1.4.9 9 | astropy==1.3 10 | Babel==2.3.4 11 | backports.shutil-get-terminal-size==1.0.0 12 | beautifulsoup4==4.5.3 13 | bitarray==0.8.1 14 | blaze==0.10.1 15 | bokeh==0.12.4 16 | boto==2.45.0 17 | botocore==1.4.93 18 | Bottleneck==1.2.0 19 | cffi==1.9.1 20 | chardet==2.3.0 21 | chest==0.2.3 22 | click==6.7 23 | cloudpickle==0.2.2 24 | clyent==1.2.2 25 | colorama==0.3.7 26 | conda==4.3.8 27 | conda-build==2.1.2 28 | conda-verify==2.0.0 29 | configobj==5.0.6 30 | contextlib2==0.5.4 31 | cryptography==1.7.1 32 | cycler==0.10.0 33 | Cython==0.25.2 34 | cytoolz==0.8.2 35 | dask==0.13.0 36 | datashape==0.5.4 37 | decorator==4.0.11 38 | dill==0.2.5 39 | Django==1.11.1 40 | docutils==0.13.1 41 | dynd==0.7.3.dev1 42 | et-xmlfile==1.0.1 43 | fastcache==1.0.2 44 | filelock==2.0.7 45 | Flask==0.12 46 | Flask-Cors==3.0.2 47 | geopy==1.11.0 48 | gevent==1.2.1 49 | greenlet==0.4.11 50 | h5py==2.6.0 51 | HeapDict==1.0.0 52 | idna==2.2 53 | imagesize==0.7.1 54 | ipykernel==4.5.2 55 | ipython==5.1.0 56 | ipython-genutils==0.1.0 57 | ipywidgets==5.2.2 58 | isort==4.2.5 59 | itsdangerous==0.24 60 | jdcal==1.3 61 | jedi==0.9.0 62 | Jinja2==2.9.4 63 | jmespath==0.9.1 64 | jsonschema==2.5.1 65 | jupyter==1.0.0 66 | jupyter-client==4.4.0 67 | jupyter-console==5.0.0 68 | jupyter-core==4.2.1 69 | lazy-object-proxy==1.2.2 70 | llvmlite==0.15.0 71 | locket==0.2.0 72 | lxml==3.7.2 73 | MarkupSafe==0.23 74 | matplotlib==2.0.0 75 | mistune==0.7.3 76 | mpmath==0.19 77 | multipledispatch==0.4.9 78 | nb-anacondacloud==1.2.0 79 | nb-conda==2.0.0 80 | nb-conda-kernels==2.0.0 81 | nbconvert==4.2.0 82 | nbformat==4.2.0 83 | nbpresent==3.0.2 84 | networkx==1.11 85 | nltk==3.2.2 86 | node==0.9.18.1 87 | nose==1.3.7 88 | notebook==4.3.1 89 | numba==0.30.1 90 | numexpr==2.6.1 91 | numpy==1.11.3 92 | numpydoc==0.6.0 93 | odict==1.5.2 94 | odo==0.5.0 95 | openpyxl==2.4.1 96 | optional-django==0.1.0 97 | pandas==0.19.2 98 | partd==0.3.7 99 | pathlib2==2.2.0 100 | patsy==0.4.1 101 | pep8==1.7.0 102 | pexpect==4.2.1 103 | pickleshare==0.7.4 104 | Pillow==4.0.0 105 | pkginfo==1.4.1 106 | pluggy==0.4.0 107 | plumber==1.3.1 108 | ply==3.9 109 | prompt-toolkit==1.0.9 110 | psutil==5.0.1 111 | ptyprocess==0.5.1 112 | py==1.4.32 113 | pyasn1==0.1.9 114 | pycosat==0.6.1 115 | pycparser==2.17 116 | pycrypto==2.6.1 117 | pycurl==7.43.0 118 | pyflakes==1.5.0 119 | Pygments==2.1.3 120 | pylint==1.6.4 121 | pyOpenSSL==16.2.0 122 | pyparsing==2.1.4 123 | pytest==3.0.5 124 | python-dateutil==2.6.0 125 | python-http-client==2.2.1 126 | pytz==2016.10 127 | PyYAML==3.12 128 | pyzmq==16.0.2 129 | QtAwesome==0.4.3 130 | qtconsole==4.2.1 131 | QtPy==1.2.1 132 | redis==2.10.5 133 | requests==2.13.0 134 | rope-py3k==0.9.4.post1 135 | s3transfer==0.1.10 136 | scikit-image==0.12.3 137 | scikit-learn==0.18.1 138 | scipy==0.18.1 139 | sendgrid==3.6.3 140 | Shapely==1.5.17.post1 141 | simplegeneric==0.8.1 142 | singledispatch==3.4.0.3 143 | six==1.10.0 144 | snowballstemmer==1.2.1 145 | sockjs-tornado==1.0.3 146 | Sphinx==1.5.1 147 | spyder==3.1.2 148 | SQLAlchemy==1.1.5 149 | statsmodels==0.6.1 150 | sympy==1.0 151 | tables==3.3.0 152 | terminado==0.6 153 | toolz==0.8.2 154 | tornado==4.4.2 155 | traitlets==4.3.1 156 | unicodecsv==0.14.1 157 | virtualenv==15.1.0 158 | wcwidth==0.1.7 159 | Werkzeug==0.11.15 160 | widgetsnbextension==1.2.6 161 | wrapt==1.10.8 162 | xlrd==1.0.0 163 | XlsxWriter==0.9.6 164 | xlwings==0.10.2 165 | xlwt==1.2.0 166 | zope.component==4.3.0 167 | zope.deprecation==4.2.0 168 | zope.event==4.2.0 169 | zope.interface==4.3.3 170 | zope.lifecycleevent==4.1.0 171 | -------------------------------------------------------------------------------- /user_models_abstractUser/user_models_abstractUser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_abstractUser/user_models_abstractUser/__init__.py -------------------------------------------------------------------------------- /user_models_abstractUser/user_models_abstractUser/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '') 6 | 7 | # SECURITY WARNING: don't run with debug turned on in production! 8 | DEBUG = True 9 | 10 | ALLOWED_HOSTS = [] 11 | 12 | INSTALLED_APPS = [ 13 | 'django.contrib.admin', 14 | 'django.contrib.auth', 15 | 'django.contrib.contenttypes', 16 | 'django.contrib.sessions', 17 | 'django.contrib.messages', 18 | 'django.contrib.staticfiles', 19 | 'abstract_user_sample', 20 | ] 21 | 22 | MIDDLEWARE = [ 23 | 'django.middleware.security.SecurityMiddleware', 24 | 'django.contrib.sessions.middleware.SessionMiddleware', 25 | 'django.middleware.common.CommonMiddleware', 26 | 'django.middleware.csrf.CsrfViewMiddleware', 27 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 28 | 'django.contrib.messages.middleware.MessageMiddleware', 29 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 30 | ] 31 | 32 | ROOT_URLCONF = 'user_models_abstractUser.urls' 33 | 34 | TEMPLATES = [ 35 | { 36 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 37 | 'DIRS': [], 38 | 'APP_DIRS': True, 39 | 'OPTIONS': { 40 | 'context_processors': [ 41 | 'django.template.context_processors.debug', 42 | 'django.template.context_processors.request', 43 | 'django.contrib.auth.context_processors.auth', 44 | 'django.contrib.messages.context_processors.messages', 45 | ], 46 | }, 47 | }, 48 | ] 49 | 50 | WSGI_APPLICATION = 'user_models_abstractUser.wsgi.application' 51 | 52 | DATABASES = { 53 | 'default': { 54 | 'ENGINE': 'django.db.backends.sqlite3', 55 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 56 | } 57 | } 58 | 59 | AUTH_USER_MODEL = 'abstract_user_sample.CustomUser' 60 | 61 | AUTH_PASSWORD_VALIDATORS = [ 62 | { 63 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 64 | }, 65 | { 66 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 67 | }, 68 | { 69 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 70 | }, 71 | { 72 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 73 | }, 74 | ] 75 | 76 | 77 | LANGUAGE_CODE = 'en-us' 78 | 79 | TIME_ZONE = 'UTC' 80 | 81 | USE_I18N = True 82 | 83 | USE_L10N = True 84 | 85 | USE_TZ = True 86 | 87 | STATIC_URL = '/static/' 88 | -------------------------------------------------------------------------------- /user_models_abstractUser/user_models_abstractUser/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | from django.contrib import admin 3 | 4 | urlpatterns = [ 5 | url(r'^admin/', admin.site.urls), 6 | url(r'', include('abstract_user_sample.urls')), 7 | ] 8 | -------------------------------------------------------------------------------- /user_models_abstractUser/user_models_abstractUser/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for user_models_abstractUser project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_abstractUser.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /user_models_oneToOne/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_oneToOne/db.sqlite3 -------------------------------------------------------------------------------- /user_models_oneToOne/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_oneToOne.settings") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_oneToOne/one_to_one_sample/__init__.py -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import CustomUser 3 | 4 | admin.site.register(CustomUser) 5 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class OneToOneSampleConfig(AppConfig): 5 | name = 'one_to_one_sample' 6 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.contrib.auth.forms import UserCreationForm 3 | from django.contrib.auth.models import User 4 | from .models import CustomUser 5 | 6 | class UserForm(UserCreationForm): 7 | class Meta(UserCreationForm.Meta): 8 | model = User 9 | fields = ('username','email',) 10 | error_css_class = 'error' 11 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_oneToOne/one_to_one_sample/migrations/__init__.py -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import User 3 | 4 | class CustomUser(models.Model): 5 | user = models.OneToOneField(User, on_delete=models.CASCADE) 6 | zip_code = models.CharField(max_length=6) 7 | 8 | def __str__(self): 9 | return self.user.username 10 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/templates/one_to_one_sample/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |This is an example of a signup form using the User model in Django.
8 | 9 |In this example, the form shows fields from the User model. There is a custom model 10 | associated with this one that includes the zip code field (email is already in the User model) 11 | but it is not shown here.
12 | 13 |All of the default Django fields are still present in the model and the database, but 14 | not shown in the form.
15 | 16 | 25 | 26 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.conf.urls import include, url 3 | from . import views 4 | 5 | urlpatterns = [ 6 | url(r'^$', views.home, name='home'), 7 | ] 8 | -------------------------------------------------------------------------------- /user_models_oneToOne/one_to_one_sample/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import HttpResponse 3 | from .forms import UserForm 4 | 5 | def home(request): 6 | if request.method == 'POST': 7 | form = UserForm(request.POST) 8 | if form.is_valid(): 9 | form.save() 10 | return HttpResponse("User was created successfully.") 11 | else: 12 | return HttpResponse("There was an error.") 13 | else: 14 | form = UserForm() 15 | 16 | return render (request, 'one_to_one_sample/home.html', {'form': form}) 17 | -------------------------------------------------------------------------------- /user_models_oneToOne/requirements.txt: -------------------------------------------------------------------------------- 1 | alabaster==0.7.9 2 | anaconda-clean==1.0 3 | anaconda-client==1.6.0 4 | anaconda-navigator==1.3.2 5 | appnope==0.1.0 6 | appscript==1.0.1 7 | argcomplete==1.0.0 8 | astroid==1.4.9 9 | astropy==1.3 10 | Babel==2.3.4 11 | backports.shutil-get-terminal-size==1.0.0 12 | beautifulsoup4==4.5.3 13 | bitarray==0.8.1 14 | blaze==0.10.1 15 | bokeh==0.12.4 16 | boto==2.45.0 17 | botocore==1.4.93 18 | Bottleneck==1.2.0 19 | cffi==1.9.1 20 | chardet==2.3.0 21 | chest==0.2.3 22 | click==6.7 23 | cloudpickle==0.2.2 24 | clyent==1.2.2 25 | colorama==0.3.7 26 | conda==4.3.8 27 | conda-build==2.1.2 28 | conda-verify==2.0.0 29 | configobj==5.0.6 30 | contextlib2==0.5.4 31 | cryptography==1.7.1 32 | cycler==0.10.0 33 | Cython==0.25.2 34 | cytoolz==0.8.2 35 | dask==0.13.0 36 | datashape==0.5.4 37 | decorator==4.0.11 38 | dill==0.2.5 39 | Django==1.11.1 40 | docutils==0.13.1 41 | dynd==0.7.3.dev1 42 | et-xmlfile==1.0.1 43 | fastcache==1.0.2 44 | filelock==2.0.7 45 | Flask==0.12 46 | Flask-Cors==3.0.2 47 | geopy==1.11.0 48 | gevent==1.2.1 49 | greenlet==0.4.11 50 | h5py==2.6.0 51 | HeapDict==1.0.0 52 | idna==2.2 53 | imagesize==0.7.1 54 | ipykernel==4.5.2 55 | ipython==5.1.0 56 | ipython-genutils==0.1.0 57 | ipywidgets==5.2.2 58 | isort==4.2.5 59 | itsdangerous==0.24 60 | jdcal==1.3 61 | jedi==0.9.0 62 | Jinja2==2.9.4 63 | jmespath==0.9.1 64 | jsonschema==2.5.1 65 | jupyter==1.0.0 66 | jupyter-client==4.4.0 67 | jupyter-console==5.0.0 68 | jupyter-core==4.2.1 69 | lazy-object-proxy==1.2.2 70 | llvmlite==0.15.0 71 | locket==0.2.0 72 | lxml==3.7.2 73 | MarkupSafe==0.23 74 | matplotlib==2.0.0 75 | mistune==0.7.3 76 | mpmath==0.19 77 | multipledispatch==0.4.9 78 | nb-anacondacloud==1.2.0 79 | nb-conda==2.0.0 80 | nb-conda-kernels==2.0.0 81 | nbconvert==4.2.0 82 | nbformat==4.2.0 83 | nbpresent==3.0.2 84 | networkx==1.11 85 | nltk==3.2.2 86 | node==0.9.18.1 87 | nose==1.3.7 88 | notebook==4.3.1 89 | numba==0.30.1 90 | numexpr==2.6.1 91 | numpy==1.11.3 92 | numpydoc==0.6.0 93 | odict==1.5.2 94 | odo==0.5.0 95 | openpyxl==2.4.1 96 | optional-django==0.1.0 97 | pandas==0.19.2 98 | partd==0.3.7 99 | pathlib2==2.2.0 100 | patsy==0.4.1 101 | pep8==1.7.0 102 | pexpect==4.2.1 103 | pickleshare==0.7.4 104 | Pillow==4.0.0 105 | pkginfo==1.4.1 106 | pluggy==0.4.0 107 | plumber==1.3.1 108 | ply==3.9 109 | prompt-toolkit==1.0.9 110 | psutil==5.0.1 111 | ptyprocess==0.5.1 112 | py==1.4.32 113 | pyasn1==0.1.9 114 | pycosat==0.6.1 115 | pycparser==2.17 116 | pycrypto==2.6.1 117 | pycurl==7.43.0 118 | pyflakes==1.5.0 119 | Pygments==2.1.3 120 | pylint==1.6.4 121 | pyOpenSSL==16.2.0 122 | pyparsing==2.1.4 123 | pytest==3.0.5 124 | python-dateutil==2.6.0 125 | python-http-client==2.2.1 126 | pytz==2016.10 127 | PyYAML==3.12 128 | pyzmq==16.0.2 129 | QtAwesome==0.4.3 130 | qtconsole==4.2.1 131 | QtPy==1.2.1 132 | redis==2.10.5 133 | requests==2.13.0 134 | rope-py3k==0.9.4.post1 135 | s3transfer==0.1.10 136 | scikit-image==0.12.3 137 | scikit-learn==0.18.1 138 | scipy==0.18.1 139 | sendgrid==3.6.3 140 | Shapely==1.5.17.post1 141 | simplegeneric==0.8.1 142 | singledispatch==3.4.0.3 143 | six==1.10.0 144 | snowballstemmer==1.2.1 145 | sockjs-tornado==1.0.3 146 | Sphinx==1.5.1 147 | spyder==3.1.2 148 | SQLAlchemy==1.1.5 149 | statsmodels==0.6.1 150 | sympy==1.0 151 | tables==3.3.0 152 | terminado==0.6 153 | toolz==0.8.2 154 | tornado==4.4.2 155 | traitlets==4.3.1 156 | unicodecsv==0.14.1 157 | virtualenv==15.1.0 158 | wcwidth==0.1.7 159 | Werkzeug==0.11.15 160 | widgetsnbextension==1.2.6 161 | wrapt==1.10.8 162 | xlrd==1.0.0 163 | XlsxWriter==0.9.6 164 | xlwings==0.10.2 165 | xlwt==1.2.0 166 | zope.component==4.3.0 167 | zope.deprecation==4.2.0 168 | zope.event==4.2.0 169 | zope.interface==4.3.3 170 | zope.lifecycleevent==4.1.0 171 | -------------------------------------------------------------------------------- /user_models_oneToOne/user_models_oneToOne/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eleanorstrib/django-user-model-options/ba6b1208897ad12678b91470cae462a7b2ebf026/user_models_oneToOne/user_models_oneToOne/__init__.py -------------------------------------------------------------------------------- /user_models_oneToOne/user_models_oneToOne/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 | 5 | SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '') 6 | 7 | # SECURITY WARNING: don't run with debug turned on in production! 8 | DEBUG = True 9 | 10 | ALLOWED_HOSTS = [] 11 | 12 | 13 | INSTALLED_APPS = [ 14 | 'django.contrib.admin', 15 | 'django.contrib.auth', 16 | 'django.contrib.contenttypes', 17 | 'django.contrib.sessions', 18 | 'django.contrib.messages', 19 | 'django.contrib.staticfiles', 20 | 'one_to_one_sample', 21 | ] 22 | 23 | MIDDLEWARE = [ 24 | 'django.middleware.security.SecurityMiddleware', 25 | 'django.contrib.sessions.middleware.SessionMiddleware', 26 | 'django.middleware.common.CommonMiddleware', 27 | 'django.middleware.csrf.CsrfViewMiddleware', 28 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 29 | 'django.contrib.messages.middleware.MessageMiddleware', 30 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 31 | ] 32 | 33 | ROOT_URLCONF = 'user_models_oneToOne.urls' 34 | 35 | TEMPLATES = [ 36 | { 37 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 38 | 'DIRS': [], 39 | 'APP_DIRS': True, 40 | 'OPTIONS': { 41 | 'context_processors': [ 42 | 'django.template.context_processors.debug', 43 | 'django.template.context_processors.request', 44 | 'django.contrib.auth.context_processors.auth', 45 | 'django.contrib.messages.context_processors.messages', 46 | ], 47 | }, 48 | }, 49 | ] 50 | 51 | WSGI_APPLICATION = 'user_models_oneToOne.wsgi.application' 52 | 53 | 54 | DATABASES = { 55 | 'default': { 56 | 'ENGINE': 'django.db.backends.sqlite3', 57 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 58 | } 59 | } 60 | 61 | 62 | AUTH_PASSWORD_VALIDATORS = [ 63 | { 64 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 65 | }, 66 | { 67 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 68 | }, 69 | { 70 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 71 | }, 72 | { 73 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 74 | }, 75 | ] 76 | 77 | 78 | LANGUAGE_CODE = 'en-us' 79 | 80 | TIME_ZONE = 'UTC' 81 | 82 | USE_I18N = True 83 | 84 | USE_L10N = True 85 | 86 | USE_TZ = True 87 | 88 | 89 | STATIC_URL = '/static/' 90 | -------------------------------------------------------------------------------- /user_models_oneToOne/user_models_oneToOne/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import include, url 2 | from django.contrib import admin 3 | 4 | urlpatterns = [ 5 | url(r'^admin/', admin.site.urls), 6 | url(r'', include('one_to_one_sample.urls')), 7 | ] 8 | -------------------------------------------------------------------------------- /user_models_oneToOne/user_models_oneToOne/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for user_models_oneToOne project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "user_models_oneToOne.settings") 15 | 16 | application = get_wsgi_application() 17 | --------------------------------------------------------------------------------