Re: confused with session chapters in djangoproject

2008-12-05 Thread vierda

Dear Karen,

thanks for your clarification. it clear now. Ok  I will try to make
the Comment model and see how it code works.

regards,
-vierda-


On Dec 6, 8:47 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 5, 2008 at 4:10 PM, vierda <[EMAIL PROTECTED]> wrote:
>
> > Dear Karen,
>
> > thanks for your reply. Actually in my learning I try to follow the
> > code which is provide in the book to understand how it works. It
> > sounds silly but from above code, I really didn't get what below line
> > trying to do :
>
> > c = comments.Comment(comment=new_comment)
>
> > somebody kindly help to clarify me, thank you.
>
> It's creating a Comment.  This particular (fictitious) Comment model
> apparently has one required argument, comment, which is being set to the
> value new_comment that has been passed into the post_comment routine.  The
> next line saves the created comment to the DB.  The real point of the
> example, though, is how the session is used to track whether a comment has
> been posted using this session yet, and to prevent more than one comment per
> session.
>
> 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
-~--~~~~--~~--~--~---



Re: confused with session chapters in djangoproject

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 4:10 PM, vierda <[EMAIL PROTECTED]> wrote:

>
> Dear Karen,
>
> thanks for your reply. Actually in my learning I try to follow the
> code which is provide in the book to understand how it works. It
> sounds silly but from above code, I really didn't get what below line
> trying to do :
>
> c = comments.Comment(comment=new_comment)
>
> somebody kindly help to clarify me, thank you.
>

It's creating a Comment.  This particular (fictitious) Comment model
apparently has one required argument, comment, which is being set to the
value new_comment that has been passed into the post_comment routine.  The
next line saves the created comment to the DB.  The real point of the
example, though, is how the session is used to track whether a comment has
been posted using this session yet, and to prevent more than one comment per
session.

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
-~--~~~~--~~--~--~---



Re: confused with session chapters in djangoproject

2008-12-05 Thread vierda

Dear Karen,

thanks for your reply. Actually in my learning I try to follow the
code which is provide in the book to understand how it works. It
sounds silly but from above code, I really didn't get what below line
trying to do :

c = comments.Comment(comment=new_comment)

somebody kindly help to clarify me, thank you.

On Dec 5, 10:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> 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
-~--~~~~--~~--~--~---



Re: confused with session chapters in djangoproject

2008-12-05 Thread Karen Tracey
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
-~--~~~~--~~--~--~---