Add part 3, use built-in user model

parent f4b661c7
...@@ -81,3 +81,11 @@ Create admin user: ...@@ -81,3 +81,11 @@ Create admin user:
Edit `urlapp/admin.py` to allow modifications to the app. Edit `urlapp/admin.py` to allow modifications to the app.
Part 3
------
Remove the `User` model and replace with that in `django.contrib.auth.models`.
python manage.py makemigrations urlapp
python manage.py migrate
...@@ -2,7 +2,6 @@ from django.contrib import admin ...@@ -2,7 +2,6 @@ from django.contrib import admin
# Register your models here. # Register your models here.
from .models import User, Url from .models import Url
admin.site.register(User)
admin.site.register(Url) admin.site.register(Url)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('urlapp', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='url',
name='user',
field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
),
migrations.DeleteModel(
name='User',
),
]
from django.contrib.auth.models import User
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class User(models.Model):
username = models.CharField(max_length=32)
password = models.CharField(max_length=128)
def __unicode__(self):
return self.username
class Url(models.Model): class Url(models.Model):
user = models.ForeignKey(User) user = models.ForeignKey(User)
target = models.CharField(max_length=256) target = models.CharField(max_length=256)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment