Add image to profile and display it in backend

This commit is contained in:
Kumi 2020-04-15 22:56:04 +02:00
parent 4b666ec1ad
commit 0e228063b6
3 changed files with 4 additions and 3 deletions

View file

@ -1,7 +1,7 @@
from polymorphic.models import PolymorphicModel from polymorphic.models import PolymorphicModel
from phonenumber_field.modelfields import PhoneNumberField from phonenumber_field.modelfields import PhoneNumberField
from django.db.models import OneToOneField, CASCADE, CharField from django.db.models import OneToOneField, CASCADE, CharField, ImageField
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
class Profile(PolymorphicModel): class Profile(PolymorphicModel):
@ -9,4 +9,5 @@ class Profile(PolymorphicModel):
mobile = PhoneNumberField(blank=True) mobile = PhoneNumberField(blank=True)
class AdminProfile(Profile): class AdminProfile(Profile):
role = CharField(max_length=64) role = CharField(max_length=64)
image = ImageField(null=True)

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View file

@ -93,7 +93,7 @@
<div class="widget-content-left"> <div class="widget-content-left">
<div class="btn-group"> <div class="btn-group">
<a data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="p-0 btn"> <a data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="p-0 btn">
<img width="42" class="rounded-circle" src="https://kumi.website/img/img-profile.png" alt=""> <img width="42" class="rounded-circle" src="{% if request.user.profile.image %}{{ request.user.profile.image.url }}{% else %}{% static "backend/images/avatars/noimage.png" %}{% endif %}" alt="">
<i class="fa fa-angle-down ml-2 opacity-8"></i> <i class="fa fa-angle-down ml-2 opacity-8"></i>
</a> </a>
<div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu dropdown-menu-right"> <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu dropdown-menu-right">