3

So, in my Django projects, I made my model to be like the following

class Store(models.Model):
    domainKey = models.CharField()

I had the above to make each store has its own domain like the following

www.domain.com/my-name-is-django

Anyway, it was perfectly working fine. But, I just found out SlugField() which is used for the same purpose as what I did in above. My question is why we need to use SlugField() because I implemented the same thing without SlugField(). Is there its own any feature that CharField() doesn't have?

Jay P.
  • 2,420
  • 6
  • 36
  • 71

1 Answers1

9

A slug is a string without special characters, in lowercase letters and with dashes instead of spaces, optimal to be used in URLs. An example of slug could be:

 example/this-is-a-slug/150

you can look for more information here Documentation django slug

CharField has max_length of 255 characters , and accept special characters.

About CharField Here

Diego Avila
  • 700
  • 7
  • 24