forked from 00dani/lemoncurry
Support for actually setting an avatar and note on the user in the admin
This commit is contained in:
parent
24c83674ba
commit
c22e807fa4
3 changed files with 15 additions and 4 deletions
|
@ -137,6 +137,9 @@ COMPRESS_PRECOMPILERS = (
|
||||||
('text/stylus', os.path.join(BASE_DIR, 'node_modules', '.bin', 'stylus') + ' {infile} -o {outfile}'),
|
('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
|
# Settings specific to lemoncurry
|
||||||
LEMONCURRY_SITE_NAME = '00dani.me'
|
LEMONCURRY_SITE_NAME = '00dani.me'
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||||
from django.contrib.auth.admin import UserAdmin
|
|
||||||
from .models import User
|
from .models import User
|
||||||
|
|
||||||
|
|
||||||
|
class UserAdmin(BaseUserAdmin):
|
||||||
|
fieldsets = BaseUserAdmin.fieldsets + (
|
||||||
|
('Profile', {'fields': ('avatar', 'note')}),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(User, UserAdmin)
|
admin.site.register(User, UserAdmin)
|
||||||
admin.site.unregister(Group)
|
|
||||||
|
|
|
@ -2,6 +2,10 @@ from django.db import models
|
||||||
from django.contrib.auth.models import AbstractUser
|
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):
|
class User(AbstractUser):
|
||||||
avatar = models.ImageField()
|
avatar = models.ImageField(upload_to=avatar_path)
|
||||||
note = models.TextField(blank=True)
|
note = models.TextField(blank=True)
|
||||||
|
|
Loading…
Reference in a new issue