ChatGPT真的太强大了,我对Django 或者说 对后端完全不懂,但是我靠Bing的ChatGPT写了瑕不掩瑜的代码,一开始我还对AI写代码半信半疑,但是说实话效果真的太香了。从今以后英语和提问的能力跟个人生产力挂钩了吧?
from django.db import models
class Stock(models.Model):
name = models.CharField(max_length=255)
class PriceHistory(models.Model):
TIMEFRAME_CHOICES = [
('1m', '1-minute'),
('5m', '5-minute'),
# add other timeframes as needed
]
stock = models.ForeignKey(
Stock,
on_delete=models.CASCADE,
related_name='price_histories',
)
date = models.DateTimeField()
price = models.DecimalField(
decimal_places=6,
max_digits=9,
)
timeframe = models.CharField(
max_length=2,
choices=TIMEFRAME_CHOICES,
)
class Meta:
unique_together = ['stock', 'date', 'price', 'timeframe']