On Fri, Dec 5, 2008 at 9:53 AM, vierda <[EMAIL PROTECTED]> wrote: > > Dear all, > > I'm newbie in Django and have started study since two weeks. I tried > code that shows in djangoproject.com, in session chapters I got > problem with below code. It shows error that says module comments > doesn't have attribute Comment. am I missing something here? > Kindly help and thank you in advance > > from django.contrib import comments > def post_comment(request, new_comment): > if request.session.get('has_commented', False): > return HttpResponse("You've already commented.") > c = comments.Comment(comment=new_comment) # got error in this line > c.save() > request.session['has_commented'] = True > return HttpResponse('Thanks for your comment!') >
That example code (which doesn't actually include "from django.contrib import comments" in the doc, which is a clue the example is not actually referring to the Django contrib.comments add-on) is trying to illustrate how to set and use session variables. As the example is focused on sessions, the referenced models aren't necessarily provided by Django. The next example uses a ficticious "Member" model which you won't find in Django either. These particular examples are not meant to be cut-and-pasted into your own code, they are simply trying to illustrate how you might use sessions with your own models. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---