I think this is because you are passing it the "Session Key" instead of the "Session Instance", you need to get the session instance and then pass it to your function, Something like this:
profile.sess = Session.objects.get(session_key=request.session.session_key) On Fri, Aug 17, 2012 at 1:28 PM, Sandeep kaur <mkaurkha...@gmail.com> wrote: > I am using session foreign key in my table. > > class ClientJob(models.Model): #models.py > ..................................... > sess = models.ForeignKey(Session) > > And in order to save its value in database, I used ,. > > def add_job(request) #views.py > ................................... > if not request.session.exists(request.session.session_key): > request.session.create() > profile.sess = request.session.session_key > profile.save() > > But when I execute my form and click on submit button, I get error as : > > ```Cannot assign "'b593c61453d7aad199078c66b9ad6b30'": > "ClientJob.sess" must be a "Session" instance.```` > > I am a bit unclear about using sessions in django, so be a little elaborative. > > Thank you. > > > -- > Sandeep Kaur > E-Mail: mkaurkha...@gmail.com > Blog: sandymadaan.wordpress.com > > -- > 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. > -- Best Regards, Amyth Arora http://techstricks.com -- 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.