How to take data from one model field to another in Django using fixture? -
i using django , have 2 model: jobs , tit_suggestion. both of them :
class title_suggestion(models.model): functional_area = models.foreignkey(jobs) job_title = models.charfield(max_length=255, blank=true, null=true) and
class jobs(models.model): name = models.charfield(max_length=255, unique=true) short_name = models.charfield(max_length=255) so , in title_suggestion field "job_title" contains data based on functional area id . , have fixture file of model.
now want load same data in new field in jobs model using fixture file. how this?? please me out. stuck here last 2 days not find relevant solution.
the short answer can't use fixture title_suggestion model populate jobs model because structure different.
in title_suggestion fixture, job specified integer representing primary key of related job, not complete object in json format.
instead, need create many job instances in fixture jobs, match foreign key instances in title_suggestion fixture.
Comments
Post a Comment