0👍
✅
del acc
But it is better to use a code like this
from django.core.exceptions import ObjectDoesNotExist
try:
acc = accounts.objects.get(twitterid=userid)
except ObjectDoesNotExist:
<<when not found>>
else:
accountcredit = acc.credit
return render_to_response('twitter_auth/info.html', locals(), context_instance=RequestContext(request))
p.s. locals() is useful for creating small views, use context={}
2👍
Just don’t use locals()
, create your own context dictionary and pass that on to the template.
context = {
'accountcredit': whatever_data_you_want
}
return render_to_response('twitter_auth/info.html', context, context_instance=RequestContext(request))
Also, using locals()
is generally a bad idea since you’re passing with everything that your function has defined as variables, which can lead some unexpected behaviour and is generally considered unsafe.
- [Answered ]-Creating new table while iterating through a queryset in django
- [Answered ]-Django auto-populate user in Createview
- [Answered ]-How to set up django to send out emails from local MTA?
- [Answered ]-Table join using the Django ORM
- [Answered ]-Using a Django project and static files in a subfolder of root
Source:stackexchange.com