Cp Verma Cp Verma - 1 year ago 61
Python Question

How to show all user list on template in django

I want to show registered users/company name list to template in django. i am new in working with django forms.
I had registered successfully company by using template now i want to show all the company name which has been registered.
my models.py

class Company(models.Model):

i am stuck that how can i show all information on template using forms. how can i make form for this and how can i get all companies name to show

I wrote this to get all companies name

def allcompanies(request):
context = RequestContext(request)
if request.method =='GET':

print "print all data",data


return render_to_response(
{ },

i get values in data but did not showing on template.

Answer Source

You should not be using render_to_response - it is likely to be depreciated in the future. You should be using render.

   from django.shortcuts import render

   return render(request, 'allcompany.html', {'data': data,})

then within your template you should have something like:

{% for company in data %}
{% endfor %}

You should do the django tutorial (or refer to it) if you haven't already, these are simple concepts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download