Re: i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-30 Thread Collin Anderson
Hi,

Is this what you're looking for?

{% url 'add_view' quotation.slug %}

Collin


On Thursday, November 27, 2014 4:26:49 PM UTC-5, Kanchan Prasad wrote:
>
> 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[\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 %}
> 
> {{quotation.title}}
> 
> {{quotation.text|truncatewords:100}}
>
> 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/d334838e-5b9f-4d2f-9b98-75c5a08265ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-28 Thread aRkadeFR

Hello Kanchan,

Sorry to say, I didn't get your question. I don't see any get_absolute_url
in your email.

And your code seems legit.

Could you provide more information about the problem?

Thank you,

aRkadeFR

On 11/27/2014 10:26 PM, Kanchan Prasad wrote:

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[\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 %}

{{quotation.title}}


{{quotation.text|truncatewords:100}}

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.


--
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/547838C3.9050108%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-27 Thread Kanchan Prasad
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[\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 %}

{{quotation.title}}

{{quotation.text|truncatewords:100}}

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.