slug

How to autofill user and slug fields in django form

How to autofill user and slug fields in django form Question: I need two of the three form fields to be filled in automatically before submitting to the database. Slug is supposed to be filled based on test_name, and user have to be filled based on data about the current user. Now I can submit …

Total answers: 1

PostDetail.post() got multiple values for argument 'slug'

PostDetail.post() got multiple values for argument 'slug' Question: I am trying to submit comments on my blog posts but I get faced with this traceback every time. When it succeeds the comment will then be subjected to moderation before showing on the website. If I could get any help it would be greatly appriciated! Here …

Total answers: 1

Django : HttpRequest.__init__() takes 1 positional argument but 2 were given

Django : HttpRequest.__init__() takes 1 positional argument but 2 were given Question: So I simply want when I click on the particular article to output its slug, for example if the slug of the given article is django-rules then i want it to be outputted as django-rules when i click on it. just that here …

Total answers: 1

not found url when use persian/arabic slug in django

not found url when use persian/arabic slug in django Question: database: mysql database Collation encode: ‘utf8_general_ci’ django version: last version python version: 3.7.12 Note : It work well in local host but not working in real host Error : models.py : class blog(models.Model): slug = models.SlugField(max_length=255,allow_unicode=True,unique=True) title = models.CharField(max_length=255) description = models.CharField(max_length=255) def __str__(self): return …

Total answers: 2

how to auto-populate slug field in django forms

how to auto-populate slug field in django forms Question: i want to allow users of a website create blog post from a form that i made, but the slug field does not get populated automatically from the frontend but from the backend (admin page) it does get populated, and that is not what i want. …

Total answers: 1

How to make Django slugify work properly with Unicode strings?

How to make Django slugify work properly with Unicode strings? Question: What can I do to prevent slugify filter from stripping out non-ASCII alphanumeric characters? (I’m using Django 1.0.2) cnprog.com has Chinese characters in question URLs, so I looked in their code. They are not using slugify in templates, instead they’re calling this method in …

Total answers: 8

What is a "slug" in Django?

What is a "slug" in Django? Question: When I read Django code I often see in models what is called a "slug". I am not quite sure what this is, but I do know it has something to do with URLs. How and when is this slug-thing supposed to be used? (I have read its …

Total answers: 13

Turn a string into a valid filename?

Turn a string into a valid filename? Question: I have a string that I want to use as a filename, so I want to remove all characters that wouldn’t be allowed in filenames, using Python. I’d rather be strict than otherwise, so let’s say I want to retain only letters, digits, and a small set …

Total answers: 27

Is there an easy way to populate SlugField from CharField?

Is there an easy way to populate SlugField from CharField? Question: class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. Asked By: ashchristopher || Source Answers: For pre-1.0: slug = models.SlugField(prepopulate_from=(‘title’,)) …

Total answers: 8