I have tried both solutions but could not achieve the results. here is
the actual code that I started working with. This is the simplest
version that I did to test this feature.

----------------------------
Model--------------------------------------
class Post (models.Model):
    name = models.CharField(max_length=1000, help_text="required, name
of the post")
    user = models.ForeignKey(User, unique=False, help_text="user this
post belongs to")

        def save(self, *args, **kwargs):
                curruser = kwargs.pop('user')
                self.user = curruser
                super(Post, self).save(*args, **kwargs)

        def __unicode__(self):
                return self.name

class PostForm(ModelForm):
        class Meta:
                model = Post
----------------------------./
Model--------------------------------------

----------------------------View--------------------------------------

@login_required
def create_post (request):
        if request.method == 'POST':
                post_form = PostForm(request.POST)
                if post_form.is_valid():
                        post = post_form.save(commit = False)
                        post.user = request.user
                        post.save()
                        return render_to_response('home.html')
                else:
                        return HttpResponse('not working')
        else:
                post_form = PostForm()
                return render_to_response('create.html', {'post_form':post_form 
})

----------------------------./
View--------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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.

Reply via email to