Giter Site home page Giter Site logo

django-ajaximage's People

Contributors

bjudson avatar bradleyg avatar gipi avatar mnorkin avatar rohanza avatar sergey-panasenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-ajaximage's Issues

Image is uploaded but it doesnt show and it can't find the url

Please, help me to implement the Ajaximage, it seems that is cant find the url, the file is stored in the proper folder, but the admin and the view cant find the image...

Project Setting:(does it need some django.contrib app??)

INSTALLED_APPS = (
....
'ajaximage',
.....

MEDIA_URL = 'media/'
MEDIA_ROOT = 'media/'

STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

AJAXIMAGE_DIR = 'media/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)

Project URL:

urlpatterns = patterns('',
url(r'^ajaximage/', include('ajaximage.urls')),

Images App URL:

urlpatterns = patterns('',
url(r'^$', views.index, name='index'),

Images App Admin:

from django.contrib import admin

from Images.models import Image
from ajaximage.fields import AjaxImageField

admin.site.register(Image)

Images App model:

from django.db import models

from ajaximage.fields import AjaxImageField

class Image(models.Model):
titulo = models.CharField(max_length=200)
data_publicacao = models.DateTimeField('date published')
thumbnail = AjaxImageField(upload_to='thumbnails',
max_height=200, #optional
max_width=200, # optional
crop=True) # optional
def unicode(self): # Python 3: def str(self):
return self.titulo
def was_published_recently(self):
return self.data_publicacao >= timezone.now() - datetime.timedelta(days=1)
def get_absolute_url(self):
return reverse('Image:detail', kwargs={'pk': self.pk})

Admin Interface:

captura de tela 2014-08-25 as 23 32 49

Admin image url:

captura de tela 2014-08-25 as 23 35 18

View index:

captura de tela 2014-08-25 as 23 56 42

Thanks!

contribute_to_class() takes exactly 3 arguments (4 given)

Hi when i syncdb i get error:

ajaximage\fields.py", line 34, in contribute_to_class
super(AjaxImageField, self).contribute_to_class(cls, name, virtual_only)
TypeError: Error when calling the metaclass bases
contribute_to_class() takes exactly 3 arguments (4 given)

then I remove virtual_only from 34 line and i get now error when I try save model:

"ajaximage\widgets.py in render, line 57"
"Error during template rendering
In template C:\Python27\lib\site-packages\django\contrib\admin\templates\admin\includes\fieldset.html, error at line 19"

If anyone have the same problem, please help me.. a try:

Replace (ajaximage\widgets.py in render, line 57):
file_url = value.url if value else ''
with:
file_url = value.url if value else str('')

error

I DO IT!!! But when i save model without name I get error about file_url = value.url if value else ''
I remove virtual_only=False and virtual_only from contribute_to_class in fields.py. THe results:
ajaximage\fields.py line 33- 35:

def contribute_to_class(self, cls, name):
super(AjaxImageField, self).contribute_to_class(cls, name)
setattr(cls, self.name, self.descriptor_class(self))

I try :
#12

Remove MEDIA_URL from filename

Thanks for the app, it's very handy, and works well on its own. The problem that I'm having is that when it saves the filename, it prepends the MEDIA_URL from settings, and always expects that to be included. This creates problems for other apps (e.g. sorl-thumbnail), which expect a path relative to MEDIA_URL, following the standard FileField behavior. It also creates problems if you were to switch between ImageField and AjaxImageField in an existing project (or change your MEDIA_URL).

I would suggest a boolean setting for prepending MEDIA_URL to the filename so as not to break existing projects (defaults to True). I can do a pull request for this if you agree with this solution.

HTTPResponse(json.dumps( doesn't work on Django 1.7

In ajaximage/views.py

return HttpResponse(json.dumps({'url': url, 'filename': path}))

should be changed to

from django.http import JsonResponse
return JsonResponse( {'url': url, 'filename': path} )

for Django 1.7+ This fixed my project.

Does not work with Grappelli

I'm not sure if it does work without Grappelli, but here are the errors I see in console when ajaximage-enabled fields are loaded:

Uncaught TypeError: Cannot call method 'ajaxTransport' of undefined jquery.iframe (transport.js:38)
Uncaught TypeError: Cannot read property 'cleanData' of undefined (jquery.ui.widget.js:24)
Uncaught TypeError: Cannot read property 'support' of undefined (jquery.fileupload.js:33)
Uncaught TypeError: Property '$' of object [object Object] is not a function (ajaximage.js:1)

The fields are completely gone, so there is not even graceful degradation.

upload_to should take callables

Like the Imagefield it replaces, upload_to could take a callable so that we can easily use directory names or filenames that contain the pk of the model.

Can I use multiple AjaxImageWidget in a single page?

I want to use multiple widgets but when I pass more than one AjaxImageUploadForm into my template their input names have the same value ( ). I checked your widgets.py and tried to change the render method's name parameter but couldn't figure out where is this function called. Is there a way to do it or if my approach is not correct how can i use multiple forms?

CSRF issue django-cookiecutter

I have tried many times, with the general instruction. but I confuse with the example. it using django-ajaximage 29 but when I using pypi to install, it just take the 28 version. The problem is with that version it makes when I try to upload image through admin page, upload proccess just stuck on load file and terminal keeps warn about "CSRF token missing or incorrect". I don't know why, but I really appreciate if you can help me

Pillow on Python3 expects bytes

Change for compatibility with Pillow/Python3 on file: ajaximage/image.py

try:
    from StringIO import StringIO as IO
except ImportError:
    from io import BytesIO as IO
....
temp = IO()

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.