How do I add data from a fileupload to a database?
For example, if I have a Book model that is for names of books and a
FileNames model that is used on a form, how do I populate Book.title.
class FileNames(models.Model):
title = models.FileField(upload_to='tmp', blank=False)
class Book(mode
2009/5/17 Patrick :
>
> How do I add data from a fileupload to a database?
> For example, if I have a Book model that is for names of books and a
> FileNames model that is used on a form, how do I populate Book.title.
>
> class FileNames(models.Model):
> title = models.FileField(upload_to='tmp'
Filenames is also a table, but I'm interested in the data withing the
file.
On May 17, 2:38 pm, Antoni Aloy wrote:
> 2009/5/17 Patrick :
>
> > How do I add data from a fileupload to a database?
> > For example, if I have a Book model that is for names of books and a
> > FileNames model that is u
On Sun, May 17, 2009 at 5:39 PM, Patrick wrote:
>
> Filenames is also a table, but I'm interested in the data withing the
> file.
>
> On May 17, 2:38 pm, Antoni Aloy wrote:
> > 2009/5/17 Patrick :
> >
> > > How do I add data from a fileupload to a database?
> > > For example, if I have a Book mo
Well, I guess what I'm confused about is adding data that doesn't come
directly from forms.
I ended up doing this and it seemed to work.
for line in file:
b=Book()
b.title=line
b.save()
Thanks
On May 17, 3:41 pm, Alex Gaynor wrote:
> On Sun, May 17, 2009 at 5:39 PM, Patrick wrote:
On May 18, 2009, at 12:12 PM, Patrick wrote:
>
> Well, I guess what I'm confused about is adding data that doesn't come
> directly from forms.
> I ended up doing this and it seemed to work.
>
> for line in file:
>b=Book()
>b.title=line
>b.save()
Here is how I do it, Model, Form, Vie
Oh, make sure your upload form specifies the 'enctype' attribute so it
will actually send a file object, like:
{% block content %}
Upload a file...
{{ form.as_p }}
{% endblock %}
--~--~-~--~~~---~--~~
You received this message because you are subscribed t
7 matches
Mail list logo