Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(models.Model):
- id = models.AutoField(primary_key=True)
- username = models.CharField(unique=True, max_length=120,blank=False)
- password = models.CharField(max_length=120, blank=True, null=False)
- class Record(models.Model):
- id = models.AutoField(primary_key=True)
- name = models.CharField(max_length=120, unique=True, blank=True)
- followers = models.ManyToManyField(User, through='Follow')
- class Record(models.Model):
- id = models.AutoField(primary_key=True)
- record = models.ForeignKey(Record)
- user = models.ForeignKey(User)
- date_followed = models.DateField(null=True, blank=True)
- {% for i in records %}
- {% if i.follow.filter(id='1').first() %}
- DO SOMETHING
- {% endif %}
- {% endfor %}
- TemplateSyntaxError at /records/
- Could not parse the remainder: '(id='1').first()' from 'i.follow.filter(id='1').first()'
- >>> x = Record.objects.first()
- >>> x.followers.filter(id='1').first()
- <User: User object>
- {% for i in accounts %}
- {% if i.follow.filter_by(user_id='1').first() %}
- DO SOMETHING
- {% endif %}
- {% endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement