I ran into the same thing in a model with a ForeignKey to an auth.User
object.  In my __repr__ function I had:

self.get_user()

which would crash Django.  In this instance, I wanted the username
specifically, so I resorted to using:

self.get_user().username

I didn't try, but I think this would have worked as well:

str(self.get_user())

I think the reason it crashed is because __repr__ should return a
string, not an object, so if you explicitly "stringify" the object,
you should be fine.  In your case, try:

str(self.someForeignKey().someThing())

-berto.

On 1/30/06, Jan Rademaker <[EMAIL PROTECTED]> wrote:
>
> What is save to use __repr__ ?
>
> I've found out that I shoud use self.get_someForeignKey().someThing()
> instead of self.someForeignKey.someThing(), but what about date fields
> and such?
>
> Because, when I use self.someDateField in __repr__ django crashes the
> moment _add_ a new object (using admin).
>
> The field is declard as:
> datum = meta.DateTimeField(auto_now_add=True)
>
> Error: TemplateSyntaxError: Caught an exception while rendering.
>
> - janr
>
>

Reply via email to