GithubHelp home page GithubHelp logo

Comments (6)

dmitry-mukhin avatar dmitry-mukhin commented on May 26, 2024

Not sure I follow.
We're talking about Django admin? You can add any extra attributes to the widget via model definition so no "custom code" is required.

@Coalpaw please elaborate.

from pyuploadcare.

Coalpaw avatar Coalpaw commented on May 26, 2024

@dmitry-mukhin You can't really do it via a model field definition (unless you know something I don't). Attributes can only be added via the widget, which I agree can be done by overriding the widget in the admin and adding the required attribs, or by tacking on the attrib to the widget during the admin init which is also a common method. However, you are already adding a custom kwarg to the ImageField (manual_crop) which automagically adds the "data-crop" attrib to the underlying custom widget. Presumably this is due to the validation of the crop string, otherwise why not leave this up to the user to implement as a widget override as well?

from pyuploadcare.

dmitry-mukhin avatar dmitry-mukhin commented on May 26, 2024

I was referring to this:
https://github.com/uploadcare/pyuploadcare/blob/master/docs/django-widget.rst#advanced-widget-options

class CandidateForm(forms.Form):
    photo = ImageField(widget=FileWidget(attrs={
        'data-cdn-base': 'https://cdn.super-candidates.com',
        'data-image-shrink': '1024x1024',
    }))

from pyuploadcare.

Coalpaw avatar Coalpaw commented on May 26, 2024

I see. That would normally be how I would do it. I guess it is a little confusing as to why there would be the "manual_crop" kwarg on the field to set a widget attrib but other uploadcare-specific attributes can't be set that way and you have to fall back to manually specifying the widget and its configuration.

from pyuploadcare.

dmitry-mukhin avatar dmitry-mukhin commented on May 26, 2024

Widget options are numerous and are being added much faster than this Django integration lib can be updated.
Also, Django lib isn't strictly connected to a particular version of the widget so some things we might add here could be absent in an older version of the widget one can choose to use for some reason.

That's why we've tried to add "native" support for some of the most used settings and give a way to set anything else that can be added in the future via widget's settings.

Let me know if you're happy and I can close the issue.

from pyuploadcare.

Coalpaw avatar Coalpaw commented on May 26, 2024

Sounds good, closing the issue.

from pyuploadcare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.