Open GoogleCodeExporter opened 9 years ago
this patch doesn´t work for me ... did you tested it?
Original comment by sehmaschine
on 2 Jun 2011 at 8:48
Sorry, my English is not good.
I hope you can understand.
I have a QuerySets object is 'q', i execute q = q.exclude({ 'Image__exact' : ''
}) Not work,i Changed can execute,i don't know why。
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 8:56
I can´t follow your usecase ... can you try this one and tell me if it works:
def get_db_prep_value(self, value, connection, prepared=False):
if not value:
return None
return value.url_save
Original comment by sehmaschine
on 2 Jun 2011 at 8:59
See the following error message:
TemplateSyntaxError at /
Caught AttributeError while rendering: 'str' object has no attribute 'url_save'
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4 pre-alpha SVN-16313
Exception Type: TemplateSyntaxError
Exception Value:
Caught AttributeError while rendering: 'str' object has no attribute 'url_save'
Exception Location: E:\Program
Files\Python26\lib\site-packages\filebrowser\fields.py in get_db_prep_value,
line 101
Python Executable: E:\Program Files\Python26\python.exe
Python Version: 2.6.5
...
E:\Program Files\Python26\lib\site-packages\filebrowser\fields.py in
get_db_prep_value
if not value or isinstance(value, FileObject):
return value
return FileObject(url_to_path(value))
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
return value.url_save
...
def formfield(self, **kwargs):
attrs = {}
attrs["directory"] = self.directory
attrs["extensions"] = self.extensions
attrs["format"] = self.format
▼ Local vars
Variable Value
connection
<django.db.backends.mysql.base.DatabaseWrapper object at 0x01721090>
self
<filebrowser.fields.FileBrowseField: Image>
value
''
prepared
True
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:04
yes ... but you didn´t include my changes. what if you change
get_db_prep_value as mentioned in comment3?
Original comment by sehmaschine
on 2 Jun 2011 at 9:07
[deleted comment]
I has changed, but the result is under my expecation, I want to check all image
uploading records.
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:24
my usecase:
>>> obj_list = BlogEntry.objects.all()
>>> obj_list
[<BlogEntry: testentry without image>, <BlogEntry: Testentry>]
>>> obj_list = BlogEntry.objects.exclude(image__exact="")
>>> obj_list
[<BlogEntry: testentry without image>]
>>> obj_list = BlogEntry.objects.filter(image__isnull=False)
>>> obj_list
[<BlogEntry: Testentry>]
Original comment by sehmaschine
on 2 Jun 2011 at 9:24
I has changed, but the result is under my expecation, I want to check all image
uploading records. Now Did not return any records.
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:25
i test again!
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:26
my query is a method! exclude parameter is the dynamic transfer, like this :
def getListQuery(excludes)
q = Article.objects.all()
q = q.exclude(**excludes)
return q
call :
list = getListQuery({ 'Image__exact' : '' })
how can i do????
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:37
I´m sorry, but that problem is not related to the filebrowser, is it?
Original comment by sehmaschine
on 2 Jun 2011 at 9:46
The previous version can execute, after updated, can't execute.
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 9:56
so, you say that this doesn´t work? can you reply and replace the "???" with
what you get ... if the list is too long, just tell me if you get what´s
expected.
>>> obj_list = Article.objects.all()
>>> obj_list
???
>>> obj_list = Article.objects.exclude(image__exact="")
>>> obj_list
???
>>> obj_list = Article.objects.filter(image__isnull=False)
>>> obj_list
???
Original comment by sehmaschine
on 2 Jun 2011 at 10:07
sorry, I do not know how to express, my English is not good.
I changed it to:
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
if isinstance(value, basestring):
return unicode(value)
return value.url_save
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 10:19
why don´t you answer my question?
Original comment by sehmaschine
on 2 Jun 2011 at 10:26
Because my english is not good, i don't know how to expression.
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 10:27
are you on skype?
Original comment by sehmaschine
on 2 Jun 2011 at 10:28
Maybe i pass a string not object
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 10:29
get_db_prep_value should look like this (see r696):
def get_db_prep_value(self, value, connection, prepared=False):
if not value:
return value
return value.url_save
Original comment by sehmaschine
on 2 Jun 2011 at 10:34
i don't konw how to explained,my value is a string not a FileObject
Original comment by Kidw...@gmail.com
on 2 Jun 2011 at 10:40
are you saying that you´re using a FileBrowseField and getting back a string
(instead of a FileObject)?
Original comment by sehmaschine
on 2 Jun 2011 at 10:43
Hi there, I have got same error:
AttributeError at /admin/lookwish/retailer/1/
'unicode' object has no attribute 'url_save'
Request Method: POST
Request URL: http://lookwish.ru:8000/admin/lookwish/retailer/1/
Django Version: 1.3
Exception Type: AttributeError
Exception Value:
'unicode' object has no attribute 'url_save'
Exception
Location: /home/zakhar/workspace/lookwish/.env/src/django-filebrowser/filebrowse
r/fields.py in get_db_prep_value, line 101
Python Executable: /home/zakhar/workspace/lookwish/.env/bin/python
Python Version: 2.7.1
Original comment by zakhar.zibarov
on 6 Jul 2011 at 9:12
Temporary I resolved problem by change get_db_prep_value to:
def get_db_prep_value(self, value, connection, prepared=False):
if value is None:
return None
if isinstance(value, FileObject):
return value.url_save
return unicode(value)
Original comment by zakhar.zibarov
on 6 Jul 2011 at 9:16
Ops, the problem was resolved at trunk.
Original comment by zakhar.zibarov
on 6 Jul 2011 at 9:37
Congratulations
Original comment by Kidw...@gmail.com
on 6 Jul 2011 at 9:42
Original issue reported on code.google.com by
Kidw...@gmail.com
on 2 Jun 2011 at 8:37Attachments: