> I am writing a django function in which I have a following list:
> li = ['a','b','c']
> I want to create a string from the list which should look like
> str = 'a,b,c'
','.join(li)
Regards,
Carlton
How are you running Django? If you are running it using
python manage.py runserver
for testing then print statements *should* cause output to appear in the
standard output stream. If you are running under Apache, however, that
is not the case.
Also note that "str" is not a happy choice of name, since it is also the
name of one of Python's basic types and you may wish to use it as such.
Having a variable called "str" in your code stops you from doing so.
A little more information will allow us to help you better.
regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/
Hi All,
I am writing a django function in which I have a following list:
li = ['a','b','c']
I want to create a string from the list which should look like
str = 'a,b,c'
I plan to pass this string to not in () function of my sql query.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
If you're using the Django ORM, you can do this without writing your own SQL.
model.objects.exclude(field__in=li)
Where model is your model class, and field is the name of the field
you want to apply the 'not in' filter on.