I am having 2 model of similar schema and I want to bulk copy from model1 
to model2  but model2 is having 3 more fields but I want to store null in 
these fields. 

class SubscriberBalanceProcess(models.Model):
    
    
    VOICE_SOC = models.CharField(max_length=50, null=True)
    SMS_SOC = models.CharField(max_length=50, null=True)
    DATA_SOC = models.CharField(max_length=50, null=True)
    DATE_TIME = models.DateTimeField(auto_now_add=True, blank=True)
    TOTAL_REMAIN_VOICE = models.BigIntegerField(default=0, null=True, 
blank=True)
    TOTAL_REMAIN_SMS = models.BigIntegerField(default=0, null=True, 
blank=True)
    TOTAL_REMAIN_DATA = models.BigIntegerField(max_length=100, null=True, 
blank=True)


    class Meta:
        db_table = "SUBSCRIBER_BALANCE_PROCESS_TEST"

class SubscriberBalance(models.Model):
    
    
    VOICE_SOC = models.CharField(max_length=50, null=True)
    SMS_SOC = models.CharField(max_length=50, null=True)
    DATA_SOC = models.CharField(max_length=50, null=True)
    DATE_TIME = models.DateTimeField(auto_now_add=True, blank=True)
    FILE_ID = models.CharField(max_length=255, null=True)


    class Meta:
        db_table = 'subscriber_balance'




SubscriberBalanceProcess.objects.bulk_create(SubscriberBalance.objects.filter(VOICE_STATUS='N',
 
SMS_FLAG=1, TENANT_ID__in=loginIdList))



Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 353, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
399, in execute
    output = self.handle(*args, **options)
  File 
"C:\Users\Development\Desktop\python\crons\management\commands\sendsms_voicebalance_process_rule_tarif.py",
 
line 74, in handle
    self.sendsmsVoicebalance()
  File 
"C:\Users\Development\Desktop\python\crons\management\commands\sendsms_voicebalance_process_rule_tarif.py",
 
line 30, in sendsms
Voicebalance
    activeMVNO = Functions.updateNonRuleMatchRecordByTarif(categoryId, type)
  File "C:\Users\Development\Desktop\python\crons\includes\functions.py", 
line 49, in updateNonRuleMatchRecordByTarif
    Functions.truncateUpdateVoice(loginIdList)
  File "C:\Users\Development\Desktop\python\crons\includes\functions.py", 
line 64, in truncateUpdateVoice
    
SubscriberBalanceProcess.objects.bulk_create(SubscriberBalance.objects.filter(VOICE_STATUS='N',
 
SMS_FLAG=1, TENANT_ID__in=loginIdL
ist))
  File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 
122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 447, 
in bulk_create
    self._batched_insert(objs_with_pk, fields, batch_size)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 
1056, in _batched_insert
    using=self.db)
  File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 
122, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 
1039, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", 
line 1059, in execute_sql
    for sql, params in self.as_sql():
  File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", 
line 1019, in as_sql
    for obj in self.query.objs
  File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", 
line 968, in pre_save_val
    return field.pre_save(obj, add=True)
  File "C:\Python27\lib\site-packages\django\db\models\fields\__init__.py", 
line 702, in pre_save
    return getattr(model_instance, self.attname)

AttributeError: 'SubscriberBalance' object has no attribute 
'TOTAL_REMAIN_VOICE'

-- 
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/1492bab8-5cbc-4308-97ab-4fc381d94a7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to