On Mar 30, 10:43 am, PhilE <l2kp...@gmail.com> wrote:
> Hi All:
>
> My first Django project is an app to manage a repository of
> downloadable software. Individual downloads have a category
> (multimedia, internet, office, etc, etc) assigned to them. Releases of
> the repository are made at regular intervals and a changelog is
> maintained in between release to track items added to/changed/removed
> from the repository. My models look like this:
>
> -----begin-----
> class Program(models.Model):
>
>     ratingChoices = (
>         (1, 'Essential'),
>         (2, 'Important'),
>         (3, 'Nice to Have'),
>         (4, 'Geeks Only'),
>     )
>
>     category = models.IntegerField(choices = categoryChoices)
>     rating = models.IntegerField(choices = ratingChoices)
>     name = models.CharField(max_length = 50)
>     version = models.CharField(max_length = 15)
>     description = models.TextField()
>     mainURL = models.URLField(verify_exists = False)
>     downloadURL = models.URLField(verify_exists = False)
>     installerPath = models.FileField(upload_to = 'downloads')
>
>     def __unicode__(self):
>         return str(self.name) + ' v' + str(self.version)
>
> class Release(models.Model):
>     version = models.CharField(max_length = 15)
>     reldate = models.DateField()
>
>     def __unicode__(self):
>         return 'v' + str(self.version) + ' (' + str(self.reldate) +
> ')'
>
> class ChangeLog(models.Model):
>     relVersion = models.ForeignKey('Release')
>     category = models.IntegerField(choices = categoryChoices)
>     logEntry = models.CharField(max_length = 100)
> ------end------
>
<snip admin code>
>
> This all works the way I want it, with the exception of the
> TabularInline thing for managing my 'Releases'. In the admin
> interface, each ChangeLog row that I've tried to Inline gets given a
> title of 'ChangeLog object'. I can't think of a particularly
> articulate way to describe what I mean, so I've posted a partial
> screen shot on my web site:
>
> http://www.linux2000.com/django-admin.png
>
> I'd like to get rid of the titles, but I can't find anything in the
> tutorials or online docs that tells me how. Anybody got any
> suggestions?


Before answering, I'd point out you have a very significant potential
bug. Each of your __unicode__ methods actually uses str(). This will
work as long as you only use ASCII values, but as soon as you have
anything else - a name with an accent, a foreign currency symbol, or
whatever - it will die horribly and you will spend ages working out
why (believe me, I've been there).

Always, always return unicode from a __unicode__ method:
        return unicode(self.name) + u' v' + unicode(self.version)

or, even better:
        return u'%s v %s' (self.name, self.version)

Now, on to the question. It's actually related, in that the value that
gets printed there is the unicode of the inline model. If you want to
change the value, define a __unicode__ on ChangeLog. But to actually
remove the value, you'll need to override the inline template. You can
copy what's in django/contrib/admin/templates/admin/edit_inline/
tabular.html and just remove lines 25-28. Place the your overridden
template somewhere in your own templates directory, and put
template='path/to/your/template.html' in the ChangeInline admin class.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to