Hi,
My forms' are never fully instantiated, particularly ImageFields (as how they would be like in admin), and TextFields (which appear as tags)
However, all other fields are instantiated properly.
May I know why this happens?
Attached code that replicates this issue:
#view
sellerForm = SellerUpgradeForm(instance=userseller_prof)
#form
class SellerUpgradeForm(ModelForm):
def __init__(self,*args, **kwargs):
super(SellerUpgradeForm, self).__init__(*args, **kwargs)
self.fields['selling_currency'].queryset = Countries.objects.filter(paypal_valid="yes")
class Meta:
model = UserSeller
fields = ("seller_store_image","shop_description","selling_currency","auth_username",
"auth_password","auth_signature")
#model
class UserSeller(models.Model):
user = models.ForeignKey(User, verbose_name="User")
access_plan = models.ForeignKey(AccessPlan, verbose_name="Seller's Access Plan")
status = models.CharField(max_length=100, choices=SELLER_STATUS, verbose_name="Seller Status", default="unapproved")
rating = models.DecimalField(verbose_name="Rating (Upon 5)", decimal_places=2, max_digits=4, default=0)
total_rating_count = models.IntegerField(verbose_name="Rating Count", default=0)
selling_currency = models.ForeignKey(Countries, verbose_name="Currency that seller's product will be sold in")
meta = models.ManyToManyField(UserMeta, verbose_name="User Meta Data", blank=True, related_name="seller_meta")
shop_description = models.TextField(verbose_name="Description about the products you are selling")
seller_store_image = models.ImageField(upload_to=settings.CUSTOM_UPLOAD_DIR, verbose_name="Store Avatar", blank=True)
internal_note = models.TextField(verbose_name="Seller Note (Internal Use Only)", blank=True)
timestamp = models.DateTimeField(verbose_name="Date Created", auto_now_add=True)
auth_username = models.CharField(max_length=50, verbose_name="Paypal Auth Username")
auth_password = models.CharField(max_length=50, verbose_name="Paypal Auth Password")
auth_signature = models.CharField(max_length=100, verbose_name="Paypal Auth Signature")
class Meta:
verbose_name = "Seller Profile"
verbose_name_plural = "Seller Profiles"
app_label = "management"
def __unicode__(self):
return "Rating: " + str(self.rating)