Hi all, i have a question on scrapy -> django integration. i have this models on django:
from django.db import models from django.utils import timezone import datetime class Job(models.Model): title = models.CharField(max_length=100) description = models.TextField(max_length=500) url = models.URLField() pub_date = models.DateTimeField('date published') rand_ord = models.FloatField(default=0) def __unicode__(self): return self.title def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) was_published_recently.admin_order_field = 'pub_date' was_published_recently.boolean = True was_published_recently.short_description = 'Published recently?' class Attribute(models.Model): description = models.CharField(max_length=50) def __unicode__(self): return self.description class JobAttribute(models.Model): attribute_id = models.ForeignKey(Attribute) job_id = models.ForeignKey(Job) value = models.CharField(max_length=50) and i'm going to write the pipeline. In scrapy i have items: from scrapy.contrib.djangoitem import DjangoItem from jobs.models import Job, JobAttribute, Attribute class JobItem(DjangoItem): django_model = Job class JobAttributeItem(DjangoItem): django_model = JobAttribute class AttributeItem(DjangoItem): django_model = Attribute in my spider i have: item = JobItem() item["url"] = response.url item["title"] = 'something' item['pub_date'] = 'something' item["description"] = 'something' item.save() Everythings work fine. But now i want to save JobAttributeItem too: item_jobattribute = JobAttributeItem() item_jobattribute['job_id'] = 'want a job object' item_jobattribute['attribute_id'] = 'what a attribute object' item_jobattribute['value'] = 'something' item_jobattribute.save() how can i do this? Thanks a lot -- 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 http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.