Wednesday, February 22, 2012

Django TypeError

Hi Guys, I'm trying to override django comments by not redirecting
users to "Thanks For The Comment" page. After inserting the codes, I'm
getting an Error:

TypeError at /comments/posted/
not enough arguments for format string
Request Method: GET
Request URL: http://127.0.0.1:8000/comments/posted/?c=23
Django Version: 1.3.1
Exception Type: TypeError Exception Value:
not enough arguments for format string
Exception Location: C:\Python27\Scripts\myweb\meekapp\models.py in
get_absolute_url, line40 Python Executable: C:\Python27\python.exe
Python Version: 2.7.2


In my Models:
class sol(models.Model):
body=models.TextField(max_length=10000)
user=models.ForeignKey(User)
date=models.DateTimeField()
state_province=models.CharField(max_length=50)
avatar=models.ImageField("Profile Pic", upload_to="photologue/
photos/", blank=True, null=True)
def __unicode__(self):
return u"%s" % (self.body)

def get_absolute_url(self):
#return u"%s" % (self.user)
return u"/%i/%i/%i/sol/%i/%s/" % (self.date.year,
self.date.month, self.date.day, self.id) #this is where python is
pointing to concerning the error.

In Views:
def comment_posted(request):
if request.GET['c']:
comment_id = request.GET['c']
comment = Comment.objects.get( pk=comment_id )
Sol = sol.objects.get(id=comment.object_pk)
if Sol:
return HttpResponseRedirect( Sol.get_absolute_url() )
return HttpResponseRedirect( "/" )

How can I get rid of this?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment