0

I have a table named tableA with columns "name" and "age" built using model.py.

Now I wanted to add another column like "gender" but this time not by changing model.py but directly through admin panel.

I know that admin panel allows to add values to the existing table but i wanted to add a feature where we can add columns too through the admin panel and not by hardcoding in model.py

So is it possible?

Rohit
  • 1
  • Does this answer your question? [How do I add a custom column with a hyperlink in the django admin interface?](https://stackoverflow.com/questions/2156114/how-do-i-add-a-custom-column-with-a-hyperlink-in-the-django-admin-interface) – Linh Nguyen Feb 26 '20 at 07:24
  • No, coz i guess the link you mentioned wants to have a clickable column, and not add fields to the model dynamically through admin panel. What i want is to customize the admin panel so that it gives us option to add new fields directly through the admin panel. – Rohit Apr 10 '20 at 14:24

2 Answers2

0

Check this answer about having dynamic models. I prefer JsonField to save data when I don't know the complete structure of model.

Glyphack
  • 876
  • 9
  • 20
0

Actually you can create a view, which one connects to DB and you can write there a creating of any column for this table using raw SQL.
But it's an awful way. In future, you will get an enormous count of different troubles.
I'd better say: it's not possible.

Sergei
  • 157
  • 1
  • 6