Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirecionar conforme limite do usuário
def get_form(self, request, obj=None, **kwargs):
form = super(EstabelecimentoAdmin, self).get_form(request, obj, **kwargs)
import pdb
pdb.set_trace()
try:
if not request.user.is_superuser:
if Usuario(user=request.user).get_limit() >= self.model.objects.filter(user=request.user).count() and obj == None:
return render_to_response('limit_places.html', {'app_label': 'Limite atingido'})
form.base_fields['cidade'].queryset = Usuario(user=request.user).get_city()
except Exception, e:
print e
finally:
return form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.