python - Separate results by comma in django -


how separate results in django template?

i have category model below

class category(models.model):     category_name = models.charfield(max_length=50)     category_slug = models.slugfield(max_length=300)     category_meta = models.textfield(max_length=300)     category_description = models.textfield(max_length=300)     listing = models.booleanfield(default=true)      def __unicode__(self):         return self.category_name 

this how print in template

<h3 class="movie-items-listing">{% category in movie.movie_category.all |join:", " %}{{ category }}{% endfor %}</h3> 

and error

templatesyntaxerror @ /movies/ 'for' statements should use format 'for x in y': category in movie.movie_category.all |join:", "

now when wanna list these, show category 1 category 2

i tried use template filters separate these keep having errors.

you using join template filter incorrectly. source

try this

{{ movie.movie_category.all|join:", " }} 

your template should this

<h3 class="movie-items-listing">{{ movie.movie_category.all|join:", " }}</h3> 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -