no such column: Schedule_footballscore.match_played

Multi tool use
Multi tool use


no such column: Schedule_footballscore.match_played


class FootballScore(models.Model):
team = models.ForeignKey(Team, related_name='teams_football', on_delete=models.CASCADE)
match_played = models.IntegerField(default='0')
lose = models.IntegerField(default='0')
win = models.IntegerField(default='0')



Initially i have team and win field only, Now i am adding new fields match_played and lose . When i am doing python manage.py makemigrations , no change is displayed, i even tried python manage.py makemigrations (my_app_name) . i also tried all the previous answers of Stackoverflow related to this topic.


migrations.CreateModel(
name='FootballScore',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('match_played', models.IntegerField(default='0')),
('lose', models.IntegerField(default='0')),
('win', models.IntegerField(default='0')),
],
),



I have seen this migration type of thing in one of the folder, is this the migrated list, because here all my fields are mentioned? Any help will be appreciated! Thanks.




1 Answer
1



The steps needed are:


0001_initial



...



Based on your example, you might not have the initial migration without the match_played column.


match_played





I am getting your point, but when i am opening my model from admin, "no such column: Schedule_footballscore.match_played" is showing :(
– Aadil Hoda
Jul 3 at 8:01





That happens when there is no such column in the physical database (MySQL/Postgres/...), i.e. when the Model does not match the database table. This is solved by creating and running migrations.
– AKX
Jul 3 at 8:04





I just commented the new fields and run makmigrations, it was there, because it was asking to remove those fields, i just removed the fields and added back and it is working fine now. Thanks. I don't know , why it was acting weird previously. Thanks a lot! @AKX
– Aadil Hoda
Jul 3 at 8:16







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

6Bc,BjGFygjUIe1AtVAcWunZg7IHXXBskGzOIA8unuZBN8IzWcn,k,T,ibvtTwgr5JCwC3
OGeeuHG57a

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications