Hello everyone, I'm trying to add comment to a custom object (here Article). This is my forms.py :
from django import forms from django.contrib.auth.models import User from myApp.models import Article class CommentForms (forms.Form): cf_comment = forms.CharField() cf_writer = forms.User() cf_date = forms.DateField() cf_article = forms.article() Here the template : <form method="post"> <input type="text" name="commentaire" /> <input type="hidden" name="user" value={{ user }} /> <input type="hidden" name="article" value={{ article }} /> <input type="submit" value="submit" /> </form> and here my view : def article(request, id): article = Article.objects.get(id=id) commentaires = Commentaire.objects.filter(article=article.id).order_by("- dateComment") # comment form if request.method == 'POST': form = CommentForms(request.POST) if form.is_valid(): #validation cf_comment = form.cleaned_data['commentaire'] cf_writer = form.cleaned_data['user'] cf_date = datetime.datetime.now() cf_article = form.cleaned_data['article'] else : form = CommentForms() c = Context({ 'Article' : article, 'commentaires' : commentaires, }) return render_to_response('myApp/article.html', c, context_instance=RequestContext(request)) When i try to go to /myapp/myArticle/id i have this message : Tried article in module app.myApp.views. Error was: 'module' object has no attribute 'User' Do you have any idea ? maybe i forge an import or maybe i can t use object in forms ... Thx for your help ! -- 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.