Skip to content

Instantly share code, notes, and snippets.

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
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
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.