Created
February 14, 2013 11:57
-
-
Save bsnux/4952342 to your computer and use it in GitHub Desktop.
Creating a Django FileField from shell
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
from django.core.files import File | |
f = File(open('path_to_file','r')) | |
m = MyModel.objects.create(one_field='value') | |
m.file_field = f | |
m.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello;
Need help for i use craete pdf in for loop have save in side object. let me know do;
c = canvas.Canvas(pdf_file + ".pdf", pagesize=A5)
for ab in ["Red","Green","Black"]:
c.save()
color.object.create(pdf=ab)