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
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):
> 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
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
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
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
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
>
> 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
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
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
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
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
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,
13 matches
Mail list logo