voronind / django-awesome-avatar Goto Github PK
View Code? Open in Web Editor NEWDjango Avatar field
Django Avatar field
If I upload an avatar called img.png
, and you upload an avatar called img.png
your avatar will replace mine. This could be used to replace another user's avatar without their consent.
Hi,I use django1.6 and modelform to change avatar,when i submit the form I got the "dict has no attribute 'url'" error and <ul class="errorlist"><li>avatar<ul class="errorlist"><li>This field cannot be blank.</li></ul></li></ul>
ใ
Anything error I made? Thanks.
Hi,
First of all, congratulations for this very useful application. I've installed it and it's working fine. However, when I'm now accessing the django admin backend and try to update user's information (e.g. add user to a group), I got following error:
'ImageFieldFile' object has no attribute '\__getitem\__'
Could you please help?
Thx in advance.
Hi, could you plese make an detailed instalation guide (something like step by step), like for beginers? (I'm stuck at point 4)...
I happened upon a couple of issues in "awesome_avatar/widgets.py". I setup a form for one to update his/her profile with a new avatar. If one does not select a file, and the submits the form, an error occurs trying to convert a string to a float in the value_from_datadict method. The "data.get(name + '-ratio', 1)" returns an empty string instead of 1 because the dict value for name + '-ration' is a unicode empty string.
Also, if that error is fixed, and you use crispy forms to display your forms, the render method in "awesome_avatar/widgets.py" also has issues as it expects value to be a django.db.models.fields.files.ImageFieldFile, and instead the type is a dict, so accessing the url member of the dict results in an error.
I have fixes for these issues, if you are interested.
I'm getting the following error:
render() got an unexpected keyword argument 'renderer'
Solution:
awesome_avatar/widgets.py:36
change
def render(self, name, value, attrs=None):
to
def render(self, name, value, attrs=None, renderer=None):
Using .width() and .height() in Webkit browsers returns sizing based on visual dimensions, not actual dimensions. This is a problem when trying to crop very large images. The HTML5 properties 'naturalHeight' and 'naturalWidth' can be used to determine the proper ratios.
I had a problem with my upload because I forgot the enctype
in my form. It is basic stuff, but can be fixed with an working example.
When I display the avatar field in a form there is no alt attribute.
<div id="id_avatar-select-area" class="awesome-avatar-select-area" style="width:200px;height:200px">
<img src="">
</div>
When I display the avatar field in a form. The page source contains src="" which is a validation error.
<div id="id_avatar-select-area" class="awesome-avatar-select-area" style="width:200px;height:200px">
<img src="">
</div>
Uncaught TypeError: $last_img.imgAreaSelect is not a function
at HTMLInputElement.<anonymous> (awesome-avatar.js:11)
at HTMLInputElement.dispatch (jquery.min.js:2)
at HTMLInputElement.v.handle (jquery.min.js:2)
upon selecting an image.
The imgAreaSelect lib is loaded.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.