def write_feed(file_obj):
 writer = csv.DictWriter(file_obj, ATTRIBUTES, dialect=csv.excel_tab)
 writer.writeheader()
 categories = Category.objects.all()
 discounts = Sale.objects.all().prefetch_related(u'products', u'categories')
 attributes_dict = {a.name: a.pk for a in ProductAttribute.objects.all()}
 attribute_values_dict = {smart_text(a.pk): smart_text(a) for a in AttributeChoiceValue.objects.all()}
 category_paths = {}
 current_site = Site.objects.get_current()
 for item in get_feed_items():
  item_data = item_attributes(item, categories, category_paths, current_site, discounts, attributes_dict, attribute_values_dict)
  writer.writerow(item_data)

def write_feed ( file_obj ) : writer = csv . DictWriter ( file_obj , ATTRIBUTES , dialect = csv . excel_tab ) writer . writeheader ( ) categories = Category . objects . all ( ) discounts = Sale . objects . all ( ) . prefetch_related ( u'products' , u'categories' ) attributes_dict = { a . name : a . pk for a in ProductAttribute . objects . all ( ) } attribute_values_dict = { smart_text ( a . pk ) : smart_text ( a ) for a in AttributeChoiceValue . objects . all ( ) } category_paths = { } current_site = Site . objects . get_current ( ) for item in get_feed_items ( ) : item_data = item_attributes ( item , categories , category_paths , current_site , discounts , attributes_dict , attribute_values_dict ) writer . writerow ( item_data )
writes feed contents info provided file object .