First model:
class Profile(models.Model):
username = models.CharField(
_('username'),
max_length=150,
unique=True,
help_text=_('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.'),
validators=[
validators.RegexValidator(
r'^[\w.@+-]+$',
_('Enter a valid username. This value may contain only '
'letters, numbers ' 'and @/./+/-/_ characters.')
),
],
error_messages={
'unique': _("A user with that username already exists."),
},
)
password = models.CharField(max_length=12, default='123456')
first_name = models.CharField(_('first name'), max_length=30, blank=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True)
email = models.EmailField(_('email address'), blank=True)
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
second model:
class UserEbiz(models.Model):
user_id = models.ForeignKey('Profile')
password = models.CharField(max_length=12, default='123456')
Tastypie Resource:
class ProfileResources(ModelResource):
id = fields.CharField(attribute='id')
class Meta:
queryset = Profile.objects.all()
resource_name = 'profile'
filtering = {
"id": ALL,
}
I want to create a function that can save a value to both table at the same time by using only one resource. My question is how to post value into Profile and UserEbiz models using ProfileResources.