Django modelform ForeignKey List
        Posted  
        
            by 
                Harry
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Harry
        
        
        
        Published on 2014-08-19T21:49:34Z
        Indexed on 
            2014/08/19
            22:20 UTC
        
        
        Read the original article
        Hit count: 250
        
django
|django-modelform
How do you get each item in the ForeignKey field in a list, for example:
class Delegate(models.Model):
    excursion = models.ForeignKey(Excursion, limit_choices_to = {'is_activity': False}, related_name='excursion', null=True, blank=True)
Template:
{% for object in formset.excursion_set.all %}
 {{ object.lable }}
 etc
{% endfor %}
My reason is that I don't want the options to display as a dropdown, but in a custom way that I will style etc.
© Stack Overflow or respective owner