How to customize table name for model classes and still use django managed tables

82 views
Skip to first unread message

Alexander Lamas

unread,
Aug 21, 2018, 3:09:52 AM8/21/18
to Django REST framework
Hi All,

I'm not sure if this is a discussion for this group.

I wonder if there is a way to stop django/python from adding the prefix "myapp" for all tables it creates when migrating.

I managed to use db_column='ColumnName' and now my tables have the column name I want, but, using db_table inside of my Meta class doesn't help anything.

I still want to keep Django to manage everything, but, not the table naming. :)

Thanks in advance!

Alex

Jani Tiainen

unread,
Aug 21, 2018, 3:54:56 AM8/21/18
to django-res...@googlegroups.com
Hi,

db_table in model Meta should definitely change table name (after migrations of course). Maybe you made some kind of a typo and it didn't worked.


--
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+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

Alexander Lamas

unread,
Aug 21, 2018, 4:08:40 AM8/21/18
to django-res...@googlegroups.com
Hi Jani,

Thanks for your reply.

Actually yes, I did the migration using the db_table and it worked as I was planning.

I was just afraid of my unit tests, but, it seems all is working as it should.

Thanks for your reply though.

Cheers,
Alex

On Tue, Aug 21, 2018 at 4:54 PM, Jani Tiainen <red...@gmail.com> wrote:
Hi,

db_table in model Meta should definitely change table name (after migrations of course). Maybe you made some kind of a typo and it didn't worked.

On Tue, Aug 21, 2018 at 10:09 AM, Alexander Lamas <alexande...@gmail.com> wrote:
Hi All,

I'm not sure if this is a discussion for this group.

I wonder if there is a way to stop django/python from adding the prefix "myapp" for all tables it creates when migrating.

I managed to use db_column='ColumnName' and now my tables have the column name I want, but, using db_table inside of my Meta class doesn't help anything.

I still want to keep Django to manage everything, but, not the table naming. :)

Thanks in advance!

Alex

--
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+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...
Reply all
Reply to author
Forward
0 new messages