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 <alex.gay...@gmail.com> wrote: > On Sun, May 17, 2009 at 5:39 PM, Patrick <whya...@gmail.com> wrote: > > > Filenames is also a table, but I'm interested in the data withing the > > file. > > > On May 17, 2:38 pm, Antoni Aloy <antoni.a...@gmail.com> wrote: > > > 2009/5/17 Patrick <whya...@gmail.com>: > > > > > 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(models.Model): > > > > title = models.CharField(max_length=30) > > > > > I'm able to upload and parse the file. I'm just not sure how to add > > > > the parsed data to Book. > > > > So FileNames is not a real table? I'm confused ... > > > > Please checkhttp:// > > docs.djangoproject.com/en/dev/topics/http/file-uploads/ > > > it would help you a lot to deal with file uploads. > > > > -- > > > Antoni Aloy López > > > Blog:http://trespams.com > > > Site:http://apsl.net > > Getting an instance of a FileName and accessing .title on it will give you a > file like object you can work with normally and extract whatever information > you want from it. I'm not 100% sure I understand your question. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---