On Thu, 2008-05-08 at 16:29 +0200, Christian Joergensen wrote: > Matthias Kestenholz wrote: > > I can think of two methods of loading Variable inside your calculate > > function: > > > > - Write the import statement in the function instead of writing it at > > the top of the module. > > You may only use module level imports* out off the main scope. And then > you could just as well import it at the top of the file as you would > otherwise. > > * that is, `import ...` not `from ... import ...`.
I'm not sure I understand. The following example may not follow good practice guidelines, but it worked for me in one of my early projects. Is this going to break sometime? Why? -- 8< -- class Entry(models.Model): author = models.ForeignKey(User) # ... def save(self): if not self.author_id from middleware import get_current_user self.author_id = get_current_user() super(Entry, self).save() -- 8< -- Thanks, Matthias --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---