how do I create a slug in Django 2.2

2019-04-09 Thread AMI FIDELE
I have tried to create a slug watch here and please tell the problem

this is model.py

from django.db import models

# this is my models
class Article(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
body = models.TextField()
date = models.DateTimeField(auto_now_add=True)


def __str__(self):
return self.title
def snippet(self):

return self.body[:90] + '...''

 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa159472-fb87-44aa-8da1-d1058ccecd5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I create a slug in Django 2.2

2019-04-09 Thread Robin Riis
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super(name, self).save(*args, **kwargs)

Den tis 9 apr. 2019 12:24AMI FIDELE  skrev:

> I have tried to create a slug watch here and please tell the problem
>
> this is model.py
>
> from django.db import models
>
> # this is my models
> class Article(models.Model):
> title = models.CharField(max_length=100)
> slug = models.SlugField()
> body = models.TextField()
> date = models.DateTimeField(auto_now_add=True)
>
>
> def __str__(self):
> return self.title
> def snippet(self):
>
> return self.body[:90] + '...''
>
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aa159472-fb87-44aa-8da1-d1058ccecd5d%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPLZMbOebd%2B_FJCpEmfdiyXzJ%3Dc4C2Kp9bvNfEWXEdfPqHSuSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.