简体   繁体   中英

Django admin export issue

admin.site.register(RegistrationOTP)    
class RegistrationOTPResource(resources.ModelResource):
    class Meta:
        model = RegistrationOTP
        export_order = ('country','phone_number','otp','created_date','is_verified')

class RegistrationOTPAdmin(ImportExportModelAdmin):
    resource_class = RegistrationOTPResource

here is models.py

class RegistrationOTP(models.Model):
    country = models.ForeignKey(Country,on_delete=models.CASCADE, related_name='otp_country', default=1)
    phone_number = models.CharField(max_length=13)#, unique=True, validators=[phone_regex],
    otp = models.PositiveIntegerField()
    created_date = models.DateTimeField(auto_now=True)
    is_verified = models.CharField(choices=YES_OR_NO, default='no', max_length=10)

    def __unicode__(self):
        return '%s : %s'% (self.phone_number, self.otp)

Here i am doing as per documentation but it is not showing export csv option in admin

class RegistrationOTPResource(resources.ModelResource):
    class Meta:
        model = RegistrationOTP
        fields = '__all__'
        export_order = ('id','country','phone_number','otp','created_date','is_verified')

try this, i guess due to missing fields section, it is not working

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM