1👍
Simply you can try like this:
if queryset:
for obj in queryset:
id = Rostering.objects.get(rosteringuser=obj.id)
obj.id = id
querysets = obj
return render(request, 'my_shift.html', {'querysets': querysets})
And in templates:
{% for object in querysets %}
<tr>
<td>{{ object.user.user_name }}</td>
<td>{{ object.id.name }}-{{ object.id.begin_time }}</td>
<td>{{ object.id.name }}-{{ object.id.end_time }}</td>
</tr>
{% endfor %}
0👍
def my_shift(request):
if request.method == 'GET':
rost_id = RosteringUser.objects.filter(user_id=request.user.id).values("rostering_user_id").first()
if rost_id :
data = Rostering.objects.get(id=rost_id['rostering_user_id'])
return render(request, 'my_shift.html', {'queryset': data })
in template you can directly display logged in username {{ request.user.first_name }}
- [Answered ]-Accessing User.get_absolute_url in Django 1.7
- [Answered ]-How to customize Date and Time field in django forms?
- [Answered ]-How to access one Cloud Datastore(Google App Engine) from Android app and django-website?
- [Answered ]-Webfaction hosted django app, shopify module will not import
- [Answered ]-Django Pagination with get_absolute_url method
Source:stackexchange.com