my model.py is
class BlogPost(models.Model):
    title        = models.CharField(max_length=100)
    text         = models.TextField()
    created_on   = models.DateTimeField(auto_now_add=True,auto_now=False)
    updated_on   = models.DateTimeField(auto_now_add=False,auto_now=True)
    submitted_by = models.ForeignKey(User)
    slug         = models.SlugField(max_length=100,unique=True)
    def __str__(self):
        return self.title
    def save(self, *args, **kwargs):
        if not self.id:
            self.slug = slugify(self.title)
            super(BlogPost,self).save(*args,**kwargs)

urls.py

url(r'^profile/latest-quotation/(?P<slug>[\w-]+)/$',add_view, 
name='add_view'),

views.py
def add_view(request,slug):
    blog = get_object_or_404(BlogPost, slug=slug)
    com_form = CommentForm(request.POST or None)
    if com_form.is_valid():
        form = com_form.save(commit=False)
        form.blogpost = blog
        form.name = request.user
        form.save()
        return HttpResponseRedirect(reverse('socialnetwrok:add_view'))
    return 
render(request,'socialnetwork/detailview.html',{'blog':blog,'com_form':com_form})

my template where i am using it
        {% for quotation in latest_quotation_list %}
            <li><h2>
        <a href="{% url 'socialnetwork:add_view' title.slug 
%}">{{quotation.title}}</a>
            </h2>    </li>
        <p>{{quotation.text|truncatewords:100}}</p>

please help me i need help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/45cb3726-5fd5-469b-b076-0eab453b95b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to