Don't save anything if error on save method

2016-04-19 Thread elcaiaimar
Hello, I' ve an application where I upload a CSV file and save all its rows in a database. This is ok, but, at the moment, when I upload the file and it exists some error on it, it saves all rows until the wrong row. What I want to achieve is that if there is an error when I save, don't save

datetime.date is not json serializable

2016-02-19 Thread elcaiaimar
Hello, I'm having a problem when I try to convert a python dictionary into a json dictionary (*json.dumps(results, ensure_ascii=False)*). Everything is ok, but when there is a date as a valure of the dictionary I get this error: datetime.date is not json serializable. I don't know how to

Send an object parameter from views.py to forms.py

2016-02-10 Thread elcaiaimar
Hello, I have a problem because I don't know how could I send one specific parameter. I've sent other parameters sometimes in others apps but this time is more difficult. Below it's my code. I want to send '*p*', which is an object. The problem is that I can't send it in *else *because I've

Re: reading CSV file with non ASCII characters

2016-02-06 Thread elcaiaimar
print titulo print pais However, when I compile it I get this error: *list indices must be integers, not str* How could I solve this problem? Thank you again El sábado, 6 de febrero de 2016, 3:14:01 (UTC+1), elcaiaimar escribió: > > Hello, > > I have a CSV File and I wan

reading CSV file with non ASCII characters

2016-02-05 Thread elcaiaimar
Hello, I have a CSV File and I want read it. The problem is that it has non ASCII characters such as 'Ñ' and accents and I need that they are recognised to save the CSV content in a DB. To simplify, I've summed up my code in django to the next: ​import csv reader =

Uncaught TypeError: Cannot read property 'value' of null

2015-03-17 Thread elcaiaimar
Hello I wonder if somebody knows how to solve the next: I want to send a value from the template to a script and it seems it works but I get an error: Uncaught TypeError: Cannot read property 'value' of null Below it is my code: *Template:* {{ obra.id }} is an object sended from views.py

Re: render_to_response and HttpResponseRedirect

2015-03-11 Thread elcaiaimar
Finally, I've changed my way to send parameters, it's much better send them by url. El miércoles, 11 de marzo de 2015, 11:21:34 (UTC+1), elcaiaimar escribió: > > Hello! > > I'm having problems in a form. I want to send some values with it to > 'obras/edicionobra.html'

render_to_response and HttpResponseRedirect

2015-03-11 Thread elcaiaimar
Hello! I'm having problems in a form. I want to send some values with it to 'obras/edicionobra.html' but I also want to redirect to the page "/edicionobra/". In the code below I send the values and I go to edicionobra.html, however, the URL is /nuevacuenca/ and that's wrong. I've tried to put

Read a csv file and save data in postgresql

2015-02-24 Thread elcaiaimar
Hello, I have a website and I need that users can introduce a csv file and save their data in a postgresql database. I can introduce a file and save it in media_dir and in the database (only the url). But what I want is save each row as a register in a table. I've searched some examples but I

Re: JSON Response

2015-02-20 Thread elcaiaimar
I solved it! Sorry, at last I had a bad called to jquery library in my base.html. I had to check all my project Thank you for your answers, you have helped me a lot! El viernes, 20 de febrero de 2015, 21:01:46 (UTC+1), elcaiaimar escribió: > > Please, have a look at this tutorial: &

Re: JSON Response

2015-02-20 Thread elcaiaimar
. He clicks on the remove button and then, an alert appears! My django version is 1.7 I hope this helps! And Thank you for your answers! El jueves, 19 de febrero de 2015, 20:14:32 (UTC+1), elcaiaimar escribió: > > Hello, > > I was wondering how I can send a response JSON in a good wa

Re: JSON Response

2015-02-19 Thread elcaiaimar
nything wrong in my code? El jueves, 19 de febrero de 2015, 21:49:59 (UTC+1), Vijay Khemlani escribió: > > What do you mean with "in a good way"? Does your code work? > > On Thu, Feb 19, 2015 at 4:14 PM, elcaiaimar <sep...@gmail.com > > wrote: > >> Hel

JSON Response

2015-02-19 Thread elcaiaimar
Hello, I was wondering how I can send a response JSON in a good way, because I have the next code: if "product_id" in request.POST: try: id_producto = request.POST['product_id'] p = Pozo.objects.get(pk=id_producto) mensaje =

JsonResponse and Ajax function.

2015-02-10 Thread elcaiaimar
Hello! I've written a code to delete db registers and I want to call an ajax function when the delete is done. At the moment, when I click my delete button I only receive a message: {"status":"True","product_id":p.id} or {"status":"False"} and this should be sent to the ajax function and I

JsonResponse and ajax function

2015-02-10 Thread elcaiaimar
Hello! I've written a code to delete db registers and I want to call an ajax function when the delete is done. At the moment, when I click my delete button I only receive a message: {"status":"True","product_id":p.id} or {"status":"False"} and this should be sent to the ajax function and I

Re: ListView and Deleteview

2015-02-02 Thread elcaiaimar
Soory, it's a class, but it doesn't work properly neither. Do I have to introduce anything in urls.py? I haven't put anything because I want the listview in a url already created. El lunes, 2 de febrero de 2015, 13:29:53 (UTC+1), elcaiaimar escribió: > > Hello everybody, > >

ListView and Deleteview

2015-02-02 Thread elcaiaimar
Hello everybody, I'm working in a website using django. I would like that users could select and delete data introduced for them. I've found some information on the web and it seems that the ListView and DeleteView is what I need. However, when I try to do a ListView, it doesn't work and I

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-25 Thread elcaiaimar
It works! You are great Collin! Thank you very much! El domingo, 16 de noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió: > > Hello everybody, I've a problem with DecimalField at Forms. I've a long > form in my template and I want to left some fields in blank. I've declared >

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-22 Thread elcaiaimar
Hi Collin I'm using postgresql db, I' ve attached my views, forms and models. I' ve thought to do the ModelForm when I solve this problem, thanks for your advice! Thank you very much! El domingo, 16 de noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió: > > Hello everybody, I've a p

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-20 Thread elcaiaimar
noviembre de 2014 18:51:43 UTC+1, elcaiaimar escribió: > > Hello everybody, I've a problem with DecimalField at Forms. I've a long > form in my template and I want to left some fields in blank. I've declared > these fields with > *required=False*, but when I submit the form I rec

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-17 Thread elcaiaimar
laces=0, blank=True, null=True) numacometidas = models.DecimalField(max_digits=2, decimal_places=0, blank=True, null=True) I think everything is ok, but if you find errors, please tell me. If not, I will try to use south. Thank you very much! El domingo, 16 de noviembre de 2014 18:51:43 UTC+1,

DecimalField returns 'This value must be a decimal number' when blank

2014-11-16 Thread elcaiaimar
Hello everybody, I've a problem with DecimalField at Forms. I've a long form in my template and I want to left some fields in blank. I've declared these fields with *required=False*, but when I submit the form I receive this error: '*This value must be a decimal number*'. I've tried to

null value in column "geom" violates not-null constraint

2014-11-13 Thread elcaiaimar
Hello everybody, I'm working with django and geodjango and now I have a problem with the geometry. I want that users can introduce coordinates in a form and then, these are saved in a database (postgis). Now, I can save X and Y coordinates, but the geom field doesn't work and I don't know why.