Skip to content

Commit 3b9b270

Browse files
Add accounts app, User model, migrations
1 parent 92b8f2e commit 3b9b270

File tree

9 files changed

+78
-1
lines changed

9 files changed

+78
-1
lines changed

accounts/__init__.py

Whitespace-only changes.

accounts/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

accounts/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AccountsConfig(AppConfig):
5+
name = 'accounts'

accounts/migrations/0001_initial.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 2.1.2 on 2018-10-03 02:11
2+
3+
import django.contrib.auth.password_validation
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='User',
17+
fields=[
18+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
20+
('created_at', models.DateTimeField(auto_now_add=True)),
21+
('updated_at', models.DateTimeField(auto_now=True)),
22+
('password', models.CharField(max_length=128, validators=[django.contrib.auth.password_validation.validate_password], verbose_name='password')),
23+
('email', models.EmailField(max_length=255, unique=True, verbose_name='email address')),
24+
('username', models.CharField(max_length=100, unique=True)),
25+
('is_active', models.BooleanField(default=True)),
26+
('is_verified', models.BooleanField(default=False)),
27+
('is_admin', models.BooleanField(default=False)),
28+
('flagged', models.BooleanField(default=False)),
29+
],
30+
options={
31+
'abstract': False,
32+
},
33+
),
34+
]

accounts/migrations/__init__.py

Whitespace-only changes.

accounts/models.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from django.db import models
2+
from django.contrib.auth.models import AbstractBaseUser
3+
from django.contrib.auth import password_validation
4+
5+
6+
class User(AbstractBaseUser):
7+
USERNAME_FIELD = 'username'
8+
9+
created_at = models.DateTimeField(auto_now_add=True)
10+
updated_at = models.DateTimeField(auto_now=True)
11+
password = models.CharField(
12+
max_length=128,
13+
verbose_name='password',
14+
validators=[password_validation.validate_password]
15+
)
16+
email = models.EmailField(
17+
verbose_name='email address',
18+
max_length=255,
19+
unique=True,
20+
)
21+
username = models.CharField(max_length=100, unique=True)
22+
is_active = models.BooleanField(default=True)
23+
is_verified = models.BooleanField(default=False)
24+
is_admin = models.BooleanField(default=False)
25+
flagged = models.BooleanField(default=False)
26+
27+
def __str__(self):
28+
return self.username

accounts/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

accounts/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

api/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'django.contrib.sessions',
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
40+
'accounts.apps.AccountsConfig',
4041
]
4142

4243
MIDDLEWARE = [
@@ -123,5 +124,5 @@
123124

124125
STATIC_URL = '/static/'
125126

126-
# AUTH_USER_MODEL = 'accounts.User'
127+
AUTH_USER_MODEL = 'accounts.User'
127128

0 commit comments

Comments
 (0)