{{{
class MyModel(models.Model):
my_field = models.ManyToManyField(AnotherModel,
through='IntermediateModel')
class IntermediateModel(models.Model):
class Meta:
db_table = 'my_intermediate_name'
my_model = models.ForeignKey(MyModel)
another_model = models.ForeignKey(AnotherModel)
}}}
I run these commands:
{{{
python manage.py makemigrations
python manage.py migrate
}}}
I'm using postgresql 9.4.4
--
Ticket URL: <https://code.djangoproject.com/ticket/25494>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi mehranakk,
I'm afraid I cannot reproduce the reported issue against the
`stable/1.8.x` and `master` branches using PostgreSQL with the provided
details.
Here's the two scenarios I've tried:
''In two steps''
1. Define the models with no explicit table name for the intermediary
model.
2. Create the initial migration via `makemigration`.
3. Alter the intermediary model definition to include an explicit table
name via the `db_table` option.
4. Create the second migration using `makemigration` and assert it
contains the appropriate `AlterModelTable` operation.
5. Run the migrations using `migrate` and assert the intermediary table
has the explicit table name as desired.
''In one step''
1. Define the models with an explicit table name for the intermediary
table via the `db_table` option.
2. Create the initial migration via `makemigration` and assert the
`CreateModel` operation has the correct `db_table` defined.
3. Run the migrations using `migrate` and assert the intermediary table
has the explicit table name as desired.
Please re-open this ticket if you can provide more info. A detailed step
by step description of the actions performed would help.
--
Ticket URL: <https://code.djangoproject.com/ticket/25494#comment:1>