Re: How to add\get data in admin via reversed relation using GenericTabularInline?

2016-10-14 Thread Anton Ponomarenko
If anyone needs to get dropdown list with selected object, instead of content_type and object_id fields, the solution is here . -- You received this message because you are subscribed to the Google Groups "Django users"

Re: How to replace content_type and object_id fields by a field with actual object in admin inline?

2016-10-14 Thread Anton Ponomarenko
Found solution. Add form to admin.TabularInline: class CriteriaPlacesInlineAdmin(admin.TabularInline): model = PlacesToCriterias form = CriteriaPlacesChoicesFieldForm # <- ADDED FORM class CriteriasAdmin(admin.ModelAdmin): inlines = [CriteriaPlacesInlineAdmin]

How to replace content_type and object_id fields by a field with actual object in admin inline?

2016-10-14 Thread Anton Ponomarenko
I have inline, which shows data of contenttype model, so instead of real objects, I see content_type and object_id fields. I can exclude these fields - this is not a problem, but also I want to get real current object as selected with other Places in a dropdown list. Could anyone tell me, how

Re: How to add\get data in admin via reversed relation using GenericTabularInline?

2016-10-13 Thread Anton Ponomarenko
It was quite easy. GenericTabularInline must be changed to admin.TabularInline class CriteriaPlacesInlineAdmin(admin.TabularInline): model = PlacesToCriterias class CriteriasAdmin(admin.ModelAdmin): inlines = [CriteriaPlacesInlineAdmin] admin.site.register(Criterias, CriteriasAdmin)

How to add\get data in admin via reversed relation using GenericTabularInline?

2016-10-13 Thread Anton Ponomarenko
Hi all. I can add Criterias to a place. How can I add Places to a criteria? Models: class Criterias(models.Model): name = ... class Places(models.Model): name = ... class PlacesToCriterias(models.Model): content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)

How to make properly choices based on two models?

2016-09-24 Thread Anton Ponomarenko
Hello. I want to let users to choose their countries. I have 2 models = *Countries* with some figures and *CountriesTranslations*. I am trying to make tuple with *country* (because user has FK to this model) and its *translation*. In front-end I see dropdown list of countries, but when I try