I have an model which uses auth.models Group as foreign key called
Dashboard:-
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
class Dashboard(models.Model):
d_name = models.CharField(max_length=200)
d_description = models.CharField(max_length=200)
d_url = models.CharField(max_length=200)
d_status = models.CharField(max_length=200)
owner = models.ForeignKey(Group)
def __str__(self):return self.d_name
<!-- end snippet -->
my views.py is:-
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
def custom_login(request):
if request.user.is_authenticated():
return HttpResponseRedirect('dashboards')
return login(request, 'login.html', authentication_form=LoginForm)
def custom_logout(request):
return logout(request, next_page='/')
def user(request):
context = {'user': user, 'groups': request.user.groups.all()}
return render_to_response('registration/dashboards.html', context,
context_instance=RequestContext(request))
<!-- end snippet -->
and here using this dashboards.html i want to display the dashboards by
using the Group_name which i will get as a result of **group.name** :-
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
{% extends "base.html" %}
{% block content %}
{% if user.is_authenticated %}
<p>Welcome, {{ request.user.get_username }}. <br/>
{% else %}
<p>Welcome, new user. Please log in.</p>
{% endif %}
<ul>
{% for group in groups %}
<li>
<strong>{{ group.name }}<strong> -
{{ dashboards.d_name }}{% if not forloop.last %},{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}
<!-- end snippet -->
here i have mentioned all the supporting information for my problem, please
let me know if there are any solution.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7eab8d65-a83d-4faa-9ac8-fee369bf04a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.