I am rendering the Django form data to a template but every time when i visit to the url it shows me this error:
_wrapped_view() takes at least 1 argument (0 given)
Method in views.py:
@login_required
def subnet_network_detail(request):
if request.method == 'POST':
form = NetworkCreateForm(request.POST)
if form.is_valid():
subnet = form.data['Subnet_Address']
ip = form.data['IP_Address']
user_hosts = get_hosts(user=request.user)
hosts_list = host_subnet(user_hosts,subnet,ip)
import pdb;pdb.set_trace()
extra_context = {
'hosts_list': hosts_list
}
return direct_to_template(request, 'networks/subnet_network.html',extra_context)
and urls.py:
url(r'^network/netmask/select/$',
'subnet_network_detail', name='subnet_network_detail')
I read from the other questions about this error but didn’t get any idea. How to solve it?
direct_to_templateis designed to be used in yoururls.py:You should be using
renderorrender_to_responsefrom within a view.If you are using django 1.3 or later you can use:
Or if you are using an earlier version: