About migration and about taggid admin

39 views
Skip to first unread message

alag...@gmail.com

unread,
Apr 2, 2015, 2:38:35 AM4/2/15
to django...@googlegroups.com
Good night guys.

I have two questions about django-taggit:

The problem is that i didn't had idea about django-taggit, but i need tag my own model, a news model, then, i built a custom keywords model, very simple model, and, for this i have two problems.
1. I have a custom admin for this model, i want to know how many childs each tag, and then i write this:
class KeyWordAdmin(ImportExportModelAdmin, admin.ModelAdmin):
    actions
= (export_as_excel,)
    list_display
= ('id','name', 'news_counter', )
    list_editable
= ('name', )
    list_filter
= ('name', )
    search_fields
= ('name', )

   
def news_counter(self, obj):
       
return obj.news.all().count() #Imprime en pantalla el numero de noticias del autor
    news_counter
.short_description = 'Noticias'
    news_counter
.allow_tags = True
# Register your models here.

admin
.site.register(KeyWord, KeyWordAdmin)

Ingresar el código aquí...
As you can see, in news_counter method i get all child of each tag and then put it the admin list.
I think that i only need how can i get the child for each django-taggit's tag and the i can rewrite taggit admin. Can you say me how can i get a num childs of a tag?

2. Well, i have a long table for Keywords model and i wan't replace my custom model for django-taggit, but i don't know how do the migration for my table, can you help me with this?

Thank you very much :D

alag...@gmail.com

unread,
Apr 2, 2015, 2:54:57 AM4/2/15
to django...@googlegroups.com, alag...@gmail.com
Ok, i have a other question:

I have a topic model, and as you can think,  i have a ForeyngKey relation between news and topic, a topic can have many news, but, a new only have a topic, how can i put this relation many to one with a custom taggit model?
Reply all
Reply to author
Forward
0 new messages