Sunday, October 31, 2010

Re: Import csv file in admin

> I try to follow the ideas, but i feel like taking the dirty way.
> Here's my work:
> Because i can't replace the modelform created by the admin for the
> "Data" model with a standard form as the Django docs says, i created a
> view to replace the "add" view generated by the admin and put a
> standard form:

Jorge,

I think you need to get back to basics and try to understand what is
run where. All the code you are writing for Django is run on the
server and only web pages are *displayed* to users on their machines.
This means that in order to import a CSV file, you need to transfer it
to the server first and then you'll be able to import it there.

Note that this has nothing to do with the admin site. This is a
fundamental think to understand.

I'd suggest that you forget the admin site for the moment and focus
on the "transfer CSV file to server first". Take a look at the email
Felix has sent you regarding FileField and try to code the part that
handles file upload to the server. Once you have that, you can start
thinking about importing the contents of the file into the database.

Cheers

Jirka

P.S. OK, there is a way to import data without uploading them to
server first, but it's much more complicated than the one outlined
above and involves multiple different technologies that have to work
together.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment