views:

43

answers:

1

I registered an app to the django admin with:

from django.contrib import admin
from MyProject.myapp.models import Model1, Model2

class HyperlinkAdmin(admin.ModelAdmin):
    pass

class Model2Admin(admin.ModelAdmin):
 pass

admin.site.register(Hyperlink, HyperlinkAdmin)
admin.site.register(Model2, Model2Admin)

Model1=

class Hyperlink(models.Model):
 url = models.URLField()

Now when I go to admin/myapp change page I see:

Hyperlink

Hyperlink object

Hyperlink object

Hyperlink object

Hyperlink object

Hyperlink object

I would like to display the name of my URL instead of "Hyperlink object" which does not tell me anything about the link behind that.

How can I achieve this?

Thanks for the time!

+1  A: 

Provide a unicode representation of model.

class Hyperlink(models.Model):
    url = models.URLField()

    def __unicode__(self):
        return self.url
Török Gábor
Thanks! Did that now I get: Caught an exception while rendering: global name 'url' is not defined
MacPython
found it myself: its return self.url !
MacPython
@MacPython: yes, sorry, fixed the code.
Török Gábor