1
You call it just like you have done, except that you don’t have anything called instance
in the template. You have a for loop that assigns each element to a variable called cv
, so you should use that.
style="width: {{ cv.get_relative_length }}px;
height: {{ cv.get_relative_length }}px;
margin-left: -{% widthratio cv.get_relative_length 2 1 %}px;
margin-top: -{% widthratio cv.get_relative_length 2 1 %}px;
"
0
models
def get_longest_post(self):
"""
Get the post object with the longest duration
Returns: longest (amount of months)
"""
longest = 0
**for post in CreateCV.objects.all():**
if post.active_post:
d2 = datetime.now()
else:
d2 = post.end_date
diff = self.get_month_diff(post.start_date, d2)
if diff > longest:
longest = diff
return longest
- Django – display informations from different models into the same HTML template
- Use of a boolean flag inside django 1.9 (template)
- Find all the objects that does not have any reverse lookup m2m values
- Best practice to handle different group of users accessing their own content
- Django. ORM filter by function's keyword argument
Source:stackexchange.com