I’m not able to wrap my head around your specific application, but if you don’t 
want to use a ForeignKey on a formset, don’t use an InlineFormset.
Just use a regular BaseFormset.
https://docs.djangoproject.com/en/2.0/topics/forms/formsets/


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Layne Sadler
Sent: Tuesday, June 5, 2018 4:04 PM
To: Django users
Subject: Inlineformset without foreign key possible?


I'm trying to implement an inline formset for two models in a graph database. 
The problem that I'm running into is that formsets are designed with foreign 
keys in mind.



I'm relating a model to itself through another model. For simplicity sake, 
let's call them a Person model and a FriendRel model:

Person -[FRIENDS_WITH]-> Person

FriendRelFormSet = inlineformset_factory(Person, FriendRel, form=FriendRelForm, 
extra=1)



I've tried setting the fk_name=None argument, but I am still met with the 
following error:



ValueError: 'django_rel.RelationshipMeta' has no ForeignKey to 
'django_node.NodeMeta'.



So now I am looking into the documentation below, but it is a bit abstract for 
my skillset. Am I banging my head against the wall with this, or is it possible 
to avoid the whole foreign key thing?

Overriding methods on an InlineFormSet   
https://docs.djangoproject.com/en/2.0/topics/forms/modelforms/#overriding-methods-on-an-inlineformset
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/dcbe2177-6593-4b6d-b0a6-6a9af3813f19%40googlegroups.com<https://groups.google.com/d/msgid/django-users/dcbe2177-6593-4b6d-b0a6-6a9af3813f19%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/c0bc1272ab194885839c717a29977411%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to