On 28/02/2018 1:26 AM, Alexander Joseph wrote:
Is there a way to make a form field or model field either a foreign
key reference or allow the user to fill in something themselves? I'm
making a fixed assets app and each fixed asset has an owner field,
which I would like to assign to an app user if possible, and if not
possible be able to fill in a name myself.
Yes. Make the ForeignKey in the model null=True and blank=True so it can
exist all alone. Then you can limit_choices_to whatever whatever suits
your requirements ...
https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to
hth
Mike
Thanks
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
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/98c44317-0993-4d41-9d25-33f8a9821dce%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/98c44317-0993-4d41-9d25-33f8a9821dce%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 [email protected].
To post to this group, send email to [email protected].
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/5b6e5c4d-5c69-ecb4-db11-d924fdd653e1%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.