Functionality to add more fields to the models

33 views
Skip to first unread message

Philip Mitchell

unread,
Apr 6, 2020, 3:22:04 AM4/6/20
to Django REST framework
Assuming I have a model User with fields first_name, last_name, and contact 
I want to have a system where if at any point the admin user will want to add other fields that were not captured he/she should be able to add them at will
assuming he wants to add age or email

how can I achieve this 

Dhruv Agarwal

unread,
Apr 6, 2020, 7:44:20 AM4/6/20
to django-res...@googlegroups.com
You can achieve this by using Custom User model in your project.

To know the way refer to documentation:

1. Extending the user model

2. Defining custom user model

Hope this helps you. 

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/ab775ca1-6f8b-4e71-a839-c8b73cc1c620%40googlegroups.com.

Philip Mitchell

unread,
Apr 6, 2020, 7:57:12 AM4/6/20
to Django REST framework
Dhruv maybe the model is not specifically the User model it can be a model Books with fields title, description, author

Lunga Baliwe

unread,
Apr 6, 2020, 8:02:48 AM4/6/20
to django-res...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.

Dhruv Agarwal

unread,
Apr 6, 2020, 8:15:08 AM4/6/20
to django-res...@googlegroups.com
If you want this kind of functionality, you should probably think of using a different DB a Non-relational one.

Or use trick like a JSON Field for storing the Dynamic Data.


JSON Field storing the dynamic fields and their values

--
Reply all
Reply to author
Forward
0 new messages