Last active
December 17, 2015 17:59
-
-
Save gladson/5650465 to your computer and use it in GitHub Desktop.
ler txt e add objetos no django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...))