On Tuesday, February 15, 2011 8:05:31 PM UTC, jonas wrote:
>
> Thanks for your reply. But I found out about save_model().
> From there I have access to the HttpRequest object that contains my
> contrib.auth.models.User model.
>
> But that seemed to be half the story.
>
> class Post(models.Model)
>>
>
> Two ways:
>
> 1) Pass the form which is creating/modifying this object the current
> request. It can then use the request object in the save() method to
> populate the field. Eg:
>
> class FooForm(forms.ModelForm):
> def __init__(self, *args, **kwargs):
>self.request = kwargs.pop('r
On Tue, Feb 15, 2011 at 3:58 PM, Jonas Geiregat wrote:
> I have a model
>
> from django.contrib.auth.models import User
>
> class Post(models.Model):
> with_some_properties = model.CharField(max_length=1)
> author = models.ForeignKey(User)
>
> def clean(self):
>
3 matches
Mail list logo