So I read the documentation on passing csrf tokens, however its giving me 
an issue i think its because im trying to pass it as a dictonary variable 
with my form and customers.

This is from the documentation

from django.views.decorators.csrf import csrf_protectfrom django.shortcuts 
import render
@csrf_protectdef my_view(request):
    c = {}
    # ...
    return render(request, "a_template.html", c)



from django.shortcuts import render
from django.http import HttpResponse
from vmware.models import Customer
from django.shortcuts import render_to_response
from vmware.models import Vms
from .forms import SignUpForm
from vmware.models import Vmspecs
from django.views.decorators.csrf import csrf_protect

@csrf_protect
def index(request):
        c = {}
        form = SignUpForm(request.POST or None)
        if form.is_valid():
                save_it = form.save(commit=False)
                save_it.save()
        customers = Customer.objects.all()
        ctx = { 'customers':customers, 'form':form, c}
        return render_to_response('index.html', ctx)



this is the error i get 


Environment:


Request Method: GET
Request URL: http://23.239.206.142:8000/

Django Version: 1.6.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'vmware')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" 
in get_response
  101.                 resolver_match = resolver.resolve(request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in resolve
  337.             for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in url_patterns
  365.         patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" 
in urlconf_module
  360.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in 
import_module
  40.         __import__(name)
File "/root/djangoprojects/provisioning/provisioning/urls.py" in <module>
  7. url(r'^customers/', include('vmware.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py" 
in include
  26.         urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in 
import_module
  40.         __import__(name)
File "/root/djangoprojects/provisioning/vmware/urls.py" in <module>
  5. from vmware import views

Exception Type: SyntaxError at /
Exception Value: invalid syntax (views.py, line 19)


-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/d9c8f4e7-1636-45d4-9877-2b01bdaf357b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to