from models import *
def info(request):
yasin = "teksaas"
if check_key(request):
api = get_api(request)
user = api.me()
userid = user.id
accounts=accounts.objects.filter(twitterid=userid)
if accounts == 1:
return render_to_response('twitter_auth/info.html', locals())
else:
registeracc=accounts(twitterid=412313,others='Hello im jsaon walker what your problem i cant unt')
registeracc.save()
return render_to_response('twitter_auth/info.html', locals())
else:
return HttpResponseRedirect(reverse('main'))
Error : local variable 'accounts' referenced before assignment
このコードを変更すると動作しますが、複数のインポート モデルは必要ありません
def info(request):
yasin = "teksaas"
if check_key(request):
from models import *
api = get_api(request)
user = api.me()
userid = user.id
accounts=accounts.objects.filter(twitterid=userid)
if accounts == 1:
return render_to_response('twitter_auth/info.html', locals())
else:
from models import *
registeracc=accounts(twitterid=412313,others='Hello im jsaon walker what your problem i cant unt')
registeracc.save()
return render_to_response('twitter_auth/info.html', locals())
else:
return HttpResponseRedirect(reverse('main'))