Discussion:
Similar structure for model
Nirali Supe
2018-06-01 19:43:23 UTC
Permalink
Hello

I need to define 2 models with same meta (same fields). One stores latest
record and other store history for those records. Instead of writing fields
in both meta, is there option in Django to achieve this?

Is there something in Django for CREATE TABLE New_Table LIKE Old_Table; ?

Thank you,
Nirali
--
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-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jani Tiainen
2018-06-01 19:55:53 UTC
Permalink
You want to read about abstract models.
Post by Nirali Supe
Hello
I need to define 2 models with same meta (same fields). One stores latest
record and other store history for those records. Instead of writing fields
in both meta, is there option in Django to achieve this?
Is there something in Django for CREATE TABLE New_Table LIKE Old_Table; ?
Thank you,
Nirali
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Samkit Jain
2018-06-02 03:50:01 UTC
Permalink
Hi Nirali,

You can add a column to specify the version for the row and all data can be
in the same table.

Or

If you still want different tables, you can create a base class with all
fields required and inherit it for creating new tables with same fields.

Hope this answers you query.

Samkit Jain,
8600086024,
http://samkit5495.github.io
Post by Nirali Supe
Hello
I need to define 2 models with same meta (same fields). One stores latest
record and other store history for those records. Instead of writing fields
in both meta, is there option in Django to achieve this?
Is there something in Django for CREATE TABLE New_Table LIKE Old_Table; ?
Thank you,
Nirali
--
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
For more options, visit https://groups.google.com/d/optout.
--
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-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...