Re: Import csv file in admin

2012-10-23 Thread Meenakshi Ithape
On Wednesday, 3 November 2010 09:34:38 UTC+5:30, Jorge wrote: > > Jirka & Everybody > > Back to basics is always a good advice. With your help and this guy: > http://www.beardygeek.com/2010/03/adding-views-to-the-django-admin/ > I can create a form to upload csv files and input their records int

Re: Import csv file in admin

2010-11-02 Thread Jorge
Jirka & Everybody Back to basics is always a good advice. With your help and this guy: http://www.beardygeek.com/2010/03/adding-views-to-the-django-admin/ I can create a form to upload csv files and input their records into the database. Short history: Forms.py: class DataInput(forms.Form):

Re: Import csv file in admin

2010-10-31 Thread Jirka Vejrazka
> 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 > stan

Re: Import csv file in admin

2010-10-30 Thread Jorge
Felix 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

Re: Import csv file in admin

2010-10-30 Thread Felix Dreissig
The ordinary user won't have to deal with the command line, you just need to get the CSV file. A ModelForm to which an FileField is added doesn't really have anything to do with that. Instead, you should create a standard form with a single FileField to upload the CSV file, save it temporarily or

Re: Import csv file in admin

2010-10-29 Thread Jorge
Jirka I need an easy method inside the admin to upload the csv file with an web interface. I guess with your method the admin will need access to the server and the command line, and something like this is not what i try to do, because the admin (not me) is not a django developer, not even a user

Re: Import csv file in admin

2010-10-29 Thread Jirka Vejrazka
I must still be missing something here. If all you want to do is to read CSV file and save the data in the database, I still don't understand why you use the forms machinery. You only *need* to use the data model, e.g. from myapp.models import Data csvfile = csv.reader('something.csv') for line

Re: Import csv file in admin

2010-10-28 Thread Jorge
> > Hang on, what you're doing here is repeatedly setting the data values > for each line to the *same* form_input model. Presumably what you > actually want to do is to create new Data instances for each line in > the CSV, with the place set to the value of the form. > > In this case, I'd recommen

Re: Import csv file in admin

2010-10-28 Thread Daniel Roseman
On Oct 28, 5:08 am, Jorge wrote: > Shame on me! > I forgot to make some changes inside the for loop. > So now it is: > >  def save(self, commit=True, *args, **kwargs): >          form_input = super(DataInput, self).save(commit=False, *args, >  **kwargs) >          form_input.place = self.cleaned_d

Re: Import csv file in admin

2010-10-27 Thread Jorge
On Oct 27, 7:43 pm, Jorge wrote: > > On 27/10/2010, Daniel Roseman wrote: > > > > You're setting the values on `self` in the form's save method. In > > > other words, you're setting them on the *form*, not the instance. You > > > should be setting them on `form_instance`. > > > > Also, don't co

Re: Import csv file in admin

2010-10-27 Thread Jorge
On Oct 27, 1:58 pm, Jirka Vejrazka wrote: > If you don't mind me asking, why do use ModelForm and not the ORM > directly? I'm just curious as using just a model (possibly wirh model > validation) seems like easies approach. > >   Cheers > >     Jirka Hi Jirka! The idea behind the modelform is

Re: Import csv file in admin

2010-10-27 Thread Daniel Roseman
On Oct 27, 4:27 am, Jorge wrote: > I'm trying to poblate a database with a csv file using the modelform > in Admin site. Here's the files: > > Models.py: > > class Data(models.Model): >         place = models.ForeignKey(Places) >         time = models.DateTimeField(blank=True) >         data_1 = m

Import csv file in admin

2010-10-27 Thread Jorge
I'm trying to poblate a database with a csv file using the modelform in Admin site. Here's the files: Models.py: class Data(models.Model): place = models.ForeignKey(Places) time = models.DateTimeField(blank=True) data_1 = models.DecimalField(max_digits=3, decimal_places=1,