django-taggit

Populate added_by field from CreateView

主宰稳场 提交于 2020-01-25 08:35:07
问题 I have extended django-taggit TagBase model to include an added_by field as a ForeignKey to User : class TagBase(models.Model): name = models.CharField(verbose_name=_("Name"), unique=True, max_length=100) slug = models.SlugField(verbose_name=_("Slug"), unique=True, max_length=100) added_by = models.ForeignKey(User, on_delete=models.CASCADE) Everything works great, however I'm having an issue with populating that field from my CreateView. This is what I have tried: class NoteCreateView

How to import django-taggit tag in django-import-export

不打扰是莪最后的温柔 提交于 2020-01-25 07:20:26
问题 I can't import Django-taggit tags using Django-import-export. This error is when the value is entered. Line number: 1 - invalid literal for int() with base 10: 'def' Also, this error is when the value is blank. Line number: 2 - Cannot add <QuerySet []> (<class 'django.db.models.query.QuerySet'>). Expected <class 'django.db.models.base.ModelBase'> or str. I also posted question in This issue. xlsx table  there is an id column too. models.py from django.db import models from django.urls import

How to import django-taggit tag in django-import-export

杀马特。学长 韩版系。学妹 提交于 2020-01-25 07:20:26
问题 I can't import Django-taggit tags using Django-import-export. This error is when the value is entered. Line number: 1 - invalid literal for int() with base 10: 'def' Also, this error is when the value is blank. Line number: 2 - Cannot add <QuerySet []> (<class 'django.db.models.query.QuerySet'>). Expected <class 'django.db.models.base.ModelBase'> or str. I also posted question in This issue. xlsx table  there is an id column too. models.py from django.db import models from django.urls import

Django __in lowercase

北慕城南 提交于 2020-01-10 04:26:05
问题 I'm using django-taggit, which handles the attachment of tags to arbitrary content types. I imported a large tag list, which contains many uppercase words, as well as lowercase words. Now, I' trying to get objects of another class containing a set of tags, but I want to compare case insensitively. When I do this: Media.objects.filter(tags__name__in=['tag1', 'tag2']) objects containing e.g. the tag "Tag1" are not found, only those ones with "tag1" or "tag2". Is there any possibility in the

How to fetch related items when using taggit in django?

只愿长相守 提交于 2020-01-06 21:11:18
问题 Using django-taggit, I'd like to fetch related posts which have the same tag(s) as the current post. Here is the views: from taggit.managers import TaggableManager, TaggedItem from taggit.models import Tag def post(request, post_slug): post = Article.objects.get(slug = post_slug) comments = Comment.objects.filter(post=post) #tag = get_object_or_404(Tag, id= post.id) #related = Article.objects.filter(tags= post.tags.similar_objects()) print "RELATED \n" #print related d = dict(post=post,

can't make autocomplete_light filter taggit tags based on request user

对着背影说爱祢 提交于 2020-01-04 08:02:28
问题 I apologize if this has nothing to do with both apps. The following snippet will throw me a "cannot filter a query once a slice has been taken": models.py class Cartao(models.Model): ... user = models.ForeignKey(settings.AUTH_USER_MODEL) tags = TaggableManager() autocomplete_light_registry.py import autocomplete_light from taggit.models import Tag class TagAutocomplete(autocomplete_light.AutocompleteModelBase): autocomplete_js_attributes={'placeholder': 'Ex: pessoal, serviços',} def choices

can't make autocomplete_light filter taggit tags based on request user

好久不见. 提交于 2020-01-04 08:02:07
问题 I apologize if this has nothing to do with both apps. The following snippet will throw me a "cannot filter a query once a slice has been taken": models.py class Cartao(models.Model): ... user = models.ForeignKey(settings.AUTH_USER_MODEL) tags = TaggableManager() autocomplete_light_registry.py import autocomplete_light from taggit.models import Tag class TagAutocomplete(autocomplete_light.AutocompleteModelBase): autocomplete_js_attributes={'placeholder': 'Ex: pessoal, serviços',} def choices

Django tag filtering issue

我的梦境 提交于 2019-12-25 04:51:57
问题 I have a problem with my code, I want to filter the tags, to show only my articles who has the a certain tag. here is my code: views.py from article.models import Article def innertag(request, id): context = {} populateContext(request, context) return render_to_response('innerajouter.html', context, Context({"articles" : Article.objects.filter(tags__name=Article.tags), "tag" : get_object_or_404(Article.tags, id=id)})) "articles" : Article.objects.filter(tags__name=Article.tags) This part of

Finding most popular tag Taggit Tastypie Django

余生颓废 提交于 2019-12-24 07:18:07
问题 Context I have been having conflict. Currenly, I am creating a question answer application. Each question has a tag, and I want to show the most popular tags (e.g. tags that have the most questions associated with it). Specifics I am using django-taggit 's TaggableManager to do so. Here is the model definition of the Question : class Question(models.Model): tags = TaggableManager() date = models.DateTimeField(default=timezone.now) text = models.TextField(null=True) So now I have the several

How to count the repetition of the elements in a list python, django

可紊 提交于 2019-12-23 12:41:14
问题 I have a django app, I am using django-taggit for my blog. Now I have a list of elements (In fact objects) that I got from database in one of my view as below tags = [<Tag: some>, <Tag: here>, <Tag: tags>, <Tag: some>, <Tag: created>, <Tag: here>, <Tag: tags>] Now how to find the count of each element in the list and return a list of tuples as below result should be as below [(<Tag: some>,2),(<Tag: here>,2),(<Tag: created>,1),(<Tag: tags>,2)] so that I can use them in template by looping it