diff --git a/application/admin.py b/application/admin.py index 4e9212b..435c9ef 100644 --- a/application/admin.py +++ b/application/admin.py @@ -6,23 +6,23 @@ from django.contrib.auth.models import User from .models import Post, CustomUser + #external code customised #import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model +#start --- class CustomUserInline(admin.StackedInline): model = CustomUser can_delete = False verbose_name_plural = 'customUsers' -#external code customised -#import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model + # Define a new User admin class UserAdmin(BaseUserAdmin): inlines = (CustomUserInline, ) -#external code customised -#import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model + # Re-register UserAdmin admin.site.unregister(User) admin.site.register(User, UserAdmin) admin.site.register(Post) - +#end --- \ No newline at end of file diff --git a/application/forms.py b/application/forms.py index 9491cab..b43c3fc 100644 --- a/application/forms.py +++ b/application/forms.py @@ -6,6 +6,7 @@ from django.forms import ModelForm, ValidationError from taggit.forms import * + #extended code customised #import from https://tutorial.djangogirls.org/en/django_forms/ class PostForm(forms.ModelForm): diff --git a/application/models.py b/application/models.py index 3ec8911..95c7b73 100644 --- a/application/models.py +++ b/application/models.py @@ -1,24 +1,29 @@ from django.db import models + from django.contrib.auth.models import User from django.utils import timezone + from taggit.managers import TaggableManager from datetime import datetime -from croniter import croniter - +#external code customised +#import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model class CustomUser(models.Model): user = models.OneToOneField(User, null=True, on_delete=models.CASCADE) + #add tags to User Model with possibility to leave empty tags = TaggableManager(blank=True) + +#external code customised +#import from https://tutorial.djangogirls.org/en/django_models/ class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() - created_date = models.DateTimeField( - default=timezone.now) - published_date = models.DateTimeField( - blank=True, null=True) + created_date = models.DateTimeField(default=timezone.now) + published_date = models.DateTimeField(blank=True, null=True) + #add tags to Post Model tags = TaggableManager() def publish(self): diff --git a/application/templates/base.html b/application/templates/base.html index 85e3555..67ee0d4 100644 --- a/application/templates/base.html +++ b/application/templates/base.html @@ -112,6 +112,7 @@ +