On Tue, Jul 17, 2012 at 02:49:49PM +0200, francescobocca...@libero.it wrote:
i have a question. In my Django views i used:
def getpath(request,user="test"):
userpathfile = FileStore.objects.get(username=user)
return userpathfile
my table FileStore contain 3 fields: id,username,path
I would like get all data from a user register (in my example "test" ) in
particular the values of path field and send the path of the files the i get to
a web page to manage some files.
I receive the below error message:
get() returned more than one FileSore -- it returned 2! Lookup parameters were
{'username': 'test'}
How i can solve it?
Not sure if I understand you correctly, but if you want to
retrieve all matching FileStore objects, you can use a filter.
https://docs.djangoproject.com/en/1.4/topics/db/queries/#retrieving-specific-objects-with-filters
If you want just the "path" field in a list, you can do something
like this:
paths = [u.path for u in FileStore.objects.filter(username=user)]
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.