Comments (8)
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.
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.
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.
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.
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.
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.
I generated a pull request for the documentation change. It also affected the bit about displaying thumbnails in the admin changelist.
from django-filebrowser.
guess this is solved due to the docs update.
from django-filebrowser.
Related Issues (20)
- Refused to connect HOT 8
- Frame loaded with http protocol HOT 4
- No clear settings HOT 4
- Select buttons disappear when Filebrowser called from CKEditor after upgrade HOT 1
- Issue with latest version
- 未来filebrowser是否考虑会添加webdev支持
- Add a `--force` flag to `python manage.py fb_version_generate`
- Should remove providing_args from the Signals
- ifequals is depreciated HOT 1
- FileBrowser is not compatible with Django 4? HOT 2
- FileBrowser permissions HOT 2
- override upload_to on save model method HOT 4
- Files with more than one extension (examples: .tar.gz, .tar.xz) are not permitted by _isAllowedExtension in filebrowser.js HOT 1
- Broken thumbnail with default settings HOT 1
- admin permission HOT 1
- doesnt work with pillow 10, please fix requirements.txt HOT 1
- Moving files between folders HOT 2
- Use absolute path for directory HOT 1
- Make Grappelli optional HOT 2
- Cannot translate the app name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-filebrowser.