我在python/django中比較新。具有3種型號,例如某些字段:如何從用戶輸入來搜索django/python中的內容?
class Card(models.Model):
id = models.AutoField(primary_key=True)
cardtype_id = models.CharField(max_length=10)
holder_name = models.CharField(max_length=100)
card_number = models.IntegerField(default=0)
email = models.EmailField(blank=True)
birthday = models.DateField(blank=True, default=None)
created = models.DateTimeField(default=timezone.now)
updated = models.DateTimeField(default=timezone.now)
strip = models.CharField(max_length=20, default="strip")
def __str__(self):
return self.holder_name
class Transaction(models.Model):
id = models.AutoField(primary_key=True)
description = models.CharField(max_length=100)
class CardTransactions(models.Model):
card = models.ForeignKey(Card, on_delete=models.CASCADE)
transaction = models.ForeignKey(Transaction, on_delete=models.CASCADE)
value = models.DecimalField(max_digits=7, decimal_places=2, blank=True)
value_date = models.DateTimeField(default=timezone.now)
created = models.DateTimeField(default=timezone.now)
description = models.CharField(max_length=200, blank=True)
table_value = models.DecimalField(max_digits=7, decimal_places=2, blank=True)
discount = models.DecimalField(max_digits=7, decimal_places=2, blank=True)
net_value = models.DecimalField(max_digits=7, decimal_places=2, blank=True)
doc_number = models.CharField(max_length=20, blank=True)
我怎麼能要求用戶輸入,例如,「CARD_NUMBER」,並打印出一個HTML頁面上的「說明」?
你有沒有通過Django的教程了:https://docs.djangoproject.com/en/2.0/intro/ tutorial01 /? – dvnguyen