Giter Club home page Giter Club logo

Comments (8)

nicksergeant avatar nicksergeant commented on July 29, 2024

Looks like this was changed to:

version_generate

Which works fine on my development, but on my server (Ubuntu 10.10 / Python 2.7.1), I get the following error:

Photo.objects.all()[0].image.version_generate('thumbnail')
AttributeError: 'NoneType' object has no attribute 'rfind'

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

sorry, but the first issue is just wrong docs (this property has never been implemented).

about the second issue: version_generate is a helper for generating versions within a view (instead of using templatetags). what exactly is your usecase?

from django-filebrowser.

nicksergeant avatar nicksergeant commented on July 29, 2024

No problem. I was using version_generate in a view like so:

p = Photo.objects.all()[0]
p.image.version_generate('thumbnail')

Assuming that that would generate the image if it didn't exists, and always return the proper path to that version.

On my local machine it works fine, but on my production server, I get this error:

AttributeError: 'NoneType' object has no attribute 'rfind'

from django-filebrowser.

nicksergeant avatar nicksergeant commented on July 29, 2024

Also, I found that if I manually created the "thumbnail" version of the image and then call "version_generate" on that object, I no longer get that error. I assumed this was permissions related but couldn't figure out why - the uploads dir had been pegged to 777 temporarily and still got the error. The web server has no problems uploading files to that directory anywhere else.

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

do you say the issue is "invalid"?

one more question (just out of curiosity): why don´t you use the templatetag to generate the version? IMO, it´s not a good practice to generate a version with the view ... but of course I have no idea about your app, so I´m just assuming.

from django-filebrowser.

nicksergeant avatar nicksergeant commented on July 29, 2024

The issue seems to be a permissions issue or some other filesystem issue, but I couldn't pinpoint the problem.

I normally use templatetags but in this case the version of the image must be generated in response to an AJAX request, and return the proper version of the image (with the image already existing), so it needs to happen in the view.

I got around this problem by generating the image this way instead of using version_generate:

def _generate_image_version(image, version_prefix='thumbnail'):
    version_path = get_version_path(image.file.name, version_prefix)
    version_path_full = smart_str(os.path.join(settings.MEDIA_ROOT, version_path))
    if not os.path.isfile(version_path_full):
        version_path = version_generator(url_to_path(image.url), version_prefix)
    return path_to_url(version_path)

photo = Photo(
    id=id,
    image=request.FILES['File']
)
photo.save()

thumbnail = _generate_image_version(photo.image, 'thumbnail')

With this approach, I do not get the 'rfind' error above.

from django-filebrowser.

sjaensch avatar sjaensch commented on July 29, 2024

I generated a pull request for the documentation change. It also affected the bit about displaying thumbnails in the admin changelist.

from django-filebrowser.

sehmaschine avatar sehmaschine commented on July 29, 2024

guess this is solved due to the docs update.

from django-filebrowser.

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.