The first field in the models.py not created, how to fix it? (django)

I have written two classes in models.py (Django): class Name_tickers(models.Model): ticker = models.CharField(max_length = 32) name = models.CharField(max_length = 100) def __str__(self): return self.ticker class Close_stock(models.Model): date = models.DateField(), tiker_name = models.ForeignKey(Name_tickers, on_delete=models.CASCADE), price = models.DecimalField(max_digits=15, decimal_places=5) But was created: migrations.CreateModel( name=’Close_stock’, fields=[ (‘id’, models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name=’ID’)), (‘price’, models.DecimalField(decimal_places=5, max_digits=15)), ], ), migrations.CreateModel( name=’Name_tickers’,… Read More The first field in the models.py not created, how to fix it? (django)

The first field in the models.py not created, how to fix it? (django)

I have written two classes in models.py (Django): class Name_tickers(models.Model): ticker = models.CharField(max_length = 32) name = models.CharField(max_length = 100) def __str__(self): return self.ticker class Close_stock(models.Model): date = models.DateField(), tiker_name = models.ForeignKey(Name_tickers, on_delete=models.CASCADE), price = models.DecimalField(max_digits=15, decimal_places=5) But was created: migrations.CreateModel( name=’Close_stock’, fields=[ (‘id’, models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name=’ID’)), (‘price’, models.DecimalField(decimal_places=5, max_digits=15)), ], ), migrations.CreateModel( name=’Name_tickers’,… Read More The first field in the models.py not created, how to fix it? (django)

Cannot correct a failed migration django

I inadvertently did this: ordering = models.IntegerField(default="Order/position") I ran makemigrations and got no error. When I ran migrate it blew up with the error: ValueError: invalid literal for int() with base 10: ‘Order/position’ what I had meant to do was this: ordering = models.IntegerField(default=0, verbose_name="Order/Position") I updated to the correct field definition and while makemigrations… Read More Cannot correct a failed migration django

Django add to wishlist

i have to do wishlist, i have done wishlist page,model and html.But when i click on the button bellow my post, im redirected to wishlist page and post didnt saved in my wishlist.So thats my code: models.py class Wishlist(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) wished_item = models.ForeignKey(Posts, on_delete=models.CASCADE) def __str__(self): return self.wished_item.title class Posts(models.Model): TYPE =… Read More Django add to wishlist

Django how to create child record with parent id

I am trying to link the accounts table with the user table using the Foreigkey field. Inside my model, I have Account class. class Account(models.Model): account_number = models.CharField(max_length=30) account_type = models.CharField(max_length=20) user = models.ForeignKey(User, related_name=’accounts’, on_delete=models.CASCADE) Below is my serializers.py class AccountSerializer(serializers.ModelSerializer): class Meta: model = Account fields = (‘id’, ‘account_number’, ‘account_type’) class UserSerializer(serializers.ModelSerializer): accounts… Read More Django how to create child record with parent id