Hey, this is an English text. I want you to translate it into the Tunisian dialect.…
- User
Hey, this is an English text. I want you to translate it into the Tunisian dialect. Please follow these steps:
- Translate step by step and highlight differences between Tunisian dialect and Modern Standard Arabic.
- Highlight sections you are confident translating into the Tunisian dialect. Translate this text into the Tunisian dialect, focusing on capturing the essence of the language nuances:
Q: Django's template cannot get a list When a list render from "view.py", template cannot get this. This is my views.py: class MyFavCourseView(LoginRequiredMixin, View): def get(self, request): course_list = [] fav_courses = UserFavorite.objects.filter(user=request.user, fav_type=1) for fav_course in fav_courses: course_id = fav_course.fav_id course = Course.objects.filter(id=course_id) course_list.append(course) return render(request, 'usercenter-fav-course.html', { "course_list": course_list }) /urls.py: url(r'^course/', include('courses.urls', namespace="course")), /courses/urls.py: url(r'^detail/(?P<course_id>\d+)/$', CourseDetailView.as_view(), name="course_detail"), a link in "usercenter-fav-course.html": {% for course in course_list %} {% endfor %} When enter this page, an error occured: https://i.stack.imgur.com/PU8Vy.png A: You have made an oversight course_id = fav_course.fav_id course = Course.objects.filter(id=course_id) course_list.append(course) By following you have appended whole course Queryset (even if it holds 1 element it is still not that element as you use only filter) as first element of an array, which makes course.id non existent or null in template world You should have get instead course_id = fav_course.fav_id # Get single course instead of filtering selection out course = Course.objects.get(id=course_id) course_list.append(course)
- Assistant