Marin
Marin

Reputation: 1331

Create new foreign key in form

I'm using django autocomplete_light and have two models connected via one-to-many relationship. Model A has a ForeignKey field TAG to model B. It all works, but I can only select the existing Tag, it is not possible to automatically add new Tag, even though it is possible to freely type in the box.

How can I "intercept" validation and create the suitable database entry for tag in time?

Upvotes: 1

Views: 156

Answers (1)

jpic
jpic

Reputation: 33410

You could use an add another popup like in django admin.

Here's a live example using this code. The design is not very very good but it demonstrates the point.

Upvotes: 1

Related Questions