Created
February 10, 2010 13:21
-
-
Save vbmendes/300299 to your computer and use it in GitHub Desktop.
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 GetAdminAddURL(self, model_class=None, model_instance=None): | |
# Se passar a classe, utiliza a classe, se passar a instancia | |
# pega a classe dela. | |
if model_class is None: | |
model_class = model_instance.__class__ | |
from django.core import urlresolvers | |
from django.contrib.contenttypes.models import ContentType | |
content_type = ContentType.objects.get_for_model(model_class) | |
return urlresolvers.reverse("admin:%s_%s_add" % (content_type.app_label, | |
content_type.model)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment