Something like https://pypi.python.org/pypi/django-genericforeignkey?
Search "django admin generic foreign key widget" for other possibilities.
On Friday, October 14, 2016 at 10:42:40 AM UTC-4, Anton Ponomarenko wrote:
> 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?
> 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)
> 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(),
> 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 post to this group, send email to email@example.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
For more options, visit https://groups.google.com/d/optout.