Skip to content

Instantly share code, notes, and snippets.

@gladson
Last active December 17, 2015 17:59
Show Gist options
  • Save gladson/5650465 to your computer and use it in GitHub Desktop.
Save gladson/5650465 to your computer and use it in GitHub Desktop.
ler txt e add objetos no django
# -*- coding: utf-8 -*-
from .models import Emails
emails = list()
with open('emails.txt') as f:
lines = f.read().splitlines()
for obj in lines:
emails.append(Emails(email=obj))
Emails.objects.bulk_create(emails)
@gladson
Copy link
Author

gladson commented Jun 4, 2013

Para add objetos que estao no models.Emails

for obj in lines:
emails.append(Emails(email=obj, field2=datetime.now(), field3=random.randint(1, 10), field4=e_por_ai_vai...))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment