~panosl/+junk/django-attachments

« back to all changes in this revision

Viewing changes to README.rst

  • Committer: Martin Mahner
  • Date: 2010-04-02 21:47:56 UTC
  • Revision ID: git-v1:8fec49fdb3310ba207c99606a2dce0898fe16d1b
Added missing linebreaks to make docutils not cry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
===============
137
137
 
138
138
First, import the items you will need::
 
139
 
139
140
    import os
140
141
    from django.core.files import File
141
142
    from attachments.models import Attachment
142
143
    from myproject.models import Person
143
144
 
144
145
Next, retrieve the object you wish to attach to::
 
146
 
145
147
    me = Person.objects.get(name='aaron')
146
148
 
147
149
Now open the attachment you want from your drive using the django File object::
 
150
 
148
151
    mypicture = File(open('/home/aaron/mypicture.jpg', 'r'))
149
152
 
150
153
Finally, create the Attachment object and save it::
 
154
 
151
155
    a = Attachment()
152
156
    a.creator = me
153
157
    a.attachment_file = mypicture