heya,

I was previously using the following to render a form:

from django.shortcuts import render_to_response, RequestContext
...
def upload_file(request):
...
return render_to_response('upload_form.html', {'form': form}, 
context_instance=RequestContext(request))

I can confirm that this works fine, form was rendered perfectly fine.

However, I read that render() is now the bee-knees...lol 
(http://stackoverflow.com/questions/5154358/django-what-is-the-difference-between-render-render-to-response-and-direct),
 
so I thought I'd switch to that:

from django.shortcuts import render
...
def upload_file(request):
...
return render('upload_form.html', {'form': form})


However, when I try to do that, I get an error:

Environment:


Request Method: GET
Request URL: http://localhost:8000/upload/

Django Version: 1.4 pre-alpha SVN-16922
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'card']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File 
"/Users/victorhooi/.virtualenvs/appname/src/django/django/core/handlers/base.py"
 
in get_response
  111.                         response = callback(request, *callback_args, 
**callback_kwargs)
File "/Users/victorhooi/djangoProjects/appname/card/views.py" in upload_file
  18.     return render('upload_form.html', {'form': form})
File 
"/Users/victorhooi/.virtualenvs/appname/src/django/django/shortcuts/__init__.py"
 
in render
  40.         context_instance = RequestContext(request, 
current_app=current_app)
File 
"/Users/victorhooi/.virtualenvs/appname/src/django/django/template/context.py" 
in __init__
  172.             self.update(processor(request))
File 
"/Users/victorhooi/.virtualenvs/appname/src/django/django/core/context_processors.py"
 
in debug
  35.     if settings.DEBUG and request.META.get('REMOTE_ADDR') in 
settings.INTERNAL_IPS:

Exception Type: AttributeError at /upload/
Exception Value: 'str' object has no attribute 'META'


Any idea from the above why this might be happening?

Thanks,
Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/f0sywLsLB28J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to