Skip to content

Commit

Permalink
Ch22: Create Profile model.
Browse files Browse the repository at this point in the history
  • Loading branch information
jambonrose committed Jul 30, 2015
1 parent 541375e commit 23e8196
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
24 changes: 24 additions & 0 deletions user/migrations/0001_initial.py
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, verbose_name='ID', primary_key=True, serialize=False)),
('slug', models.SlugField(unique=True, max_length=30)),
('about', models.TextField()),
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)),
],
),
]
13 changes: 12 additions & 1 deletion user/models.py
@@ -1,3 +1,14 @@
from django.conf import settings
from django.db import models

# Create your models here.

class Profile(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL)
slug = models.SlugField(
max_length=30,
unique=True)
about = models.TextField()

def __str__(self):
return self.user.get_username()

0 comments on commit 23e8196

Please sign in to comment.