Skip to main content

Avatar django model field

Project description

Django-awesome-avatar is a reusable application providing Avatar model field. It allows crop selected area before saving image.

Purpose

  • field in profile model instead creating model for saving images

  • HTML FileAPI instead hidden iframe ajax for image preview

  • easy customizable presence (any view and widget templates)

Usage

To integrate django-awesome-avatar with your site, there are few things that are required:

  1. pip install django-awesome-avatar

#. List this application in the INSTALLED_APPS portion of your settings file. Your settings file will look something like:

INSTALLED_APPS = (
    ...
    'awesome_avatar',
)
  1. Add the AvatarField to your profile model:

    from awesome_avatar.fields import AvatarField
    
    class Profile(Model):
        ...
        avatar = AvatarField(upload_to='avatars', width=100, height=100)
  2. And for example, use in ModelForm:

    class AvatarChangeForm(ModelForm):
        class Meta:
            model = Profile
            fields = ['avatar']
    
    ...
    return render(request, template, {'form': AvatarChangeForm})

Global Settings

settings.py:

AWESOME_AVATAR = {
    'width': 100,
    'height': 100,

    'select_area_width': 400,
    'select_area_height': 300,

    'save_quality': 90,
    'save_format': 'png',
    ...
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-awesome-avatar-1.0.3.tar.gz (59.6 kB view details)

Uploaded Source

File details

Details for the file django-awesome-avatar-1.0.3.tar.gz.

File metadata

File hashes

Hashes for django-awesome-avatar-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e91b056754b5165087f2928bd986719e292edacaf34ae95fcc3aa04eb67d83f3
MD5 41753ae7de796ca657fe2c6cbf160607
BLAKE2b-256 6e78d9048b211409f39b37ba9787f1c3f20b35ef129e8bb93f535145cd7e317c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page