-
-
Notifications
You must be signed in to change notification settings - Fork 624
Closed
Description
I am working on an Arabic blog and whenever I insert the tags in Arabic it saves the tag's slug as an empty string.
is there a way to allow Unicode tags slugs?
Models
class Post(models.Model, HitCountMixin):
title = models.CharField(max_length=255)
slug = models.SlugField(unique=True, allow_unicode=True)
summary = models.CharField(max_length=500)
header_image = models.ImageField(null=True, blank=True, upload_to="images/")
tags = TaggableManager()
author = models.ForeignKey(User, on_delete=models.CASCADE)
body = RichTextField(blank=True, null=True)
post_date = models.DateField(auto_now_add=True)
update_date = models.DateField(auto_now=True)
category = models.ForeignKey(Category, related_name='posts', on_delete=models.CASCADE)
featured = models.BooleanField(default=False)
views = GenericRelation(HitCount, object_id_field='object_pk',related_query_name='hit_count_generic_relation')
Forms
class AddPostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title','summary', 'body', 'header_image', 'category', 'tags')
labels = {
"title": "العنوان",
"tags": "العلامات",
"category": "التصنيف",
"summary":"الملخص",
"body": "المحتوى",
"header_image": "الغلاف",
}
widgets = {
'title': forms.TextInput(attrs={'class':'form-control'}),
'tags': forms.TextInput(attrs={'class':'form-control', 'data-role':"tagsinput", 'name':"tags"}),
'category': forms.Select(choices=choices_list, attrs={'class':'form-control'}),
'summary': forms.TextInput(attrs={'class':'form-control'}),
'header_image': forms.FileInput(attrs={'class':'form-control'}),
'body': forms.Textarea(attrs={'class':'form-control'}),
}
Views
class AddPostView(CreateView):
model = Post
form_class = AddPostForm
template_name = 'add_post.html'
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
Metadata
Metadata
Assignees
Labels
No labels