Created
June 29, 2012 20:23
-
-
Save robrocker7/3020428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choose_state(request): | |
# try to auto find the city/state from IP address | |
geo_ip = GeoIP() | |
city_info = geo_ip.city('12.201.194.50') | |
if city_info is not None and 'city' in city_info and 'region' in city_info and 'dont_auto_crime_stats' not in request.session: | |
request.session['dont_auto_crime_stats'] = True | |
return HttpResponseRedirect(reverse('crime-rate:crime-stats', kwargs={'city': city_info['city'], 'state': city_info['region']})) | |
states = State.objects.order_by('name') | |
forms = {} | |
forms['basic'] = PAContactForm() | |
return render_to_response('crime-stats/choose-state.html', | |
{'states': states, | |
'forms': forms,}, | |
context_instance=RequestContext(request)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment