hi everyone: i defined tbls customer and salesorder in my db, i want to show the customer name in my form but want not to save it in salesorder tbl, how can i initial it for gui? my code is : #model class Customer(models.Model): name=models.CharField(max_length=40) abbreviation=models.CharField(max_length=20)
class SalesOrder(models.Model): customer=models.ForeignKey(Customer,related_name='by_customer',on_delete=models.CASCADE) #form class SalesOrderForm(forms.ModelForm): customer_name=forms.CharField(required=False,widget=forms.TextInput(attrs={'readonly':''})) class Meta: model=SalesOrder fields = ['customer','customer_name',] thanks 1351552...@qq.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/201607011405183921218%40qq.com. For more options, visit https://groups.google.com/d/optout.