Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode support #754

Closed
AnasBuhayh opened this issue Sep 28, 2021 · 8 comments
Closed

Unicode support #754

AnasBuhayh opened this issue Sep 28, 2021 · 8 comments

Comments

@AnasBuhayh
Copy link

AnasBuhayh commented Sep 28, 2021

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)
@auvipy
Copy link
Contributor

auvipy commented Sep 28, 2021

mmm.... can you try encode utf-8 ?

@AnasBuhayh
Copy link
Author

Hi @auvipy. try it where?

@sergeyklay
Copy link
Member

@AnasBuhayh It sounds strange to me. I have used Cyrillic for tags and have not seen any issues with taggit.

@AnasBuhayh
Copy link
Author

@AnasBuhayh It sounds strange to me. I have used Cyrillic for tags and have not seen any issues with taggit.

@sergeyklay I am really sorry but I found out that I didn't mention that my issue was with the slugs! the tag is saved but the slug associated with that tag is saved as an empty string.

sorry again for the confusion

@AnasBuhayh
Copy link
Author

I think that someone tried to fix this #572

@rtpg
Copy link
Contributor

rtpg commented May 2, 2022

This should be fixed in django-taggit 3.0.0!

@rtpg rtpg closed this as completed May 2, 2022
@AliIslamov
Copy link

@AnasBuhayh It sounds strange to me. I have used Cyrillic for tags and have not seen any issues with taggit.

I try to use Django-taggit, but it saves all tags with Cyrillic slugs.

How can I fix it?

@AliIslamov
Copy link

This should be fixed in django-taggit 3.0.0!

I have taggit v4.0 but this problem still actual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants