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 
can I do this?


Model:

class Criterias(models.Model):
    name = ...
class Places(models.Model):
    name = ...
class PlacesToCriterias(models.Model):
    content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
    object_id = models.PositiveIntegerField()
    content_object = GenericForeignKey()

    criteria_group = models.ForeignKey(Criterias)

Admin:

class CriteriaPlacesInlineAdmin(admin.TabularInline):
    model = PlacesToCriterias
class CriteriasAdmin(admin.ModelAdmin):
    inlines = [CriteriaPlacesInlineAdmin]

admin.site.register(Criterias, CriteriasAdmin)

I can add to CriteriaPlacesInlineAdmin a form, something like:

class CriteriaPlacesChoicesFieldForm(forms.ModelForm):
    places = forms.ModelChoiceField(PlaceTypesGroups.objects.all(), 
label='place')

but how can I pass\add object_id to this form\query in order to get 
'selected' place in the dropdown list?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/240fdcdb-8083-4d5a-b116-a52144dded17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to