Created
August 20, 2013 18:04
-
-
Save gtsalles/6284965 to your computer and use it in GitHub Desktop.
Demonstration of formfield_for_foreignkey method on Django.
This file contains 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 formfield_for_foreignkey(self, db_field, request, **kwargs): | |
if db_field.name == "usuario": | |
usuario_id = request.GET.get('usuario_id', None) | |
if usuario_id: | |
kwargs['initial'] = usuario_id | |
if db_field.name == "psicologo": | |
kwargs["queryset"] = User.objects.filter(is_superuser=True) | |
return super(EntrevistaAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment