Browse Source

Support for actually setting an avatar and note on the user in the admin

pull/1/head
Danielle McLean 5 years ago
parent
commit
c22e807fa4
Signed by: 00dani
GPG Key ID: 5A5D2D1AFF12EEC5
  1. 3
      lemoncurry/settings/base.py
  2. 10
      users/admin.py
  3. 6
      users/models.py

3
lemoncurry/settings/base.py

@ -137,6 +137,9 @@ COMPRESS_PRECOMPILERS = (
('text/stylus', os.path.join(BASE_DIR, 'node_modules', '.bin', 'stylus') + ' {infile} -o {outfile}'),
)
MEDIA_URL = STATIC_URL + 'media/'
MEDIA_ROOT = os.path.join(STATIC_ROOT, 'media')
# Settings specific to lemoncurry
LEMONCURRY_SITE_NAME = '00dani.me'

10
users/admin.py

@ -1,8 +1,12 @@
from django.contrib import admin
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from .models import User
class UserAdmin(BaseUserAdmin):
fieldsets = BaseUserAdmin.fieldsets + (
('Profile', {'fields': ('avatar', 'note')}),
)
admin.site.register(User, UserAdmin)
admin.site.unregister(Group)

6
users/models.py

@ -2,6 +2,10 @@ from django.db import models
from django.contrib.auth.models import AbstractUser
def avatar_path(instance, name):
return 'avatars/{id}/{name}'.format(id=instance.id, name=name)
class User(AbstractUser):
avatar = models.ImageField()
avatar = models.ImageField(upload_to=avatar_path)
note = models.TextField(blank=True)

Loading…
Cancel
Save