Tuesday, July 16, 2013

Re: save data from html table

I presume that you mean an HTML table.

Didn't you already have to have the data in order to render the template?

Or are you using a template that someone else has rendered, that you have, in python, as a string?  If this, then there are many libraries that can parse a DOM for you.  If it is XHTML (legal XML) the lxml is a personal favorite.  You can then extract the data as strings.  You will need to know which field might be numbers and convert them yourself.  Similar for booleans, etc.  The ORM might  help you with these last conversions.

Or are you updating a table in the browser, using some JavaScript that allows the user to create rows and/or modify cells.  In that case I'd be using jQuery to extract the values into JavaScript objects, and bundle them as JSON to send to the view.  You still have type conversion, which you could do on either the JavaScript or Python side.

Or are you doing something else entirely?


On Tue, Jul 16, 2013 at 9:07 AM, Randa Hisham <randahesham@gmail.com> wrote:
my problem not to save to database but is how to get data from template


On Tue, Jul 16, 2013 at 3:03 PM, Lukas Nemec <lu.nemec@gmail.com> wrote:
That depends, you could use django.db models to access that table,
but that depends on the table - there is a ton of information on this subject here:

https://docs.djangoproject.com/en/dev/topics/db/models/

Or, you could write a custom SQL that would fetch exactly the data you want, and
save it in dict or list ... and you have this data inside view ...



On 07/16/2013 03:00 PM, Randa Hisham wrote:
if i have dynami table in my template contain data
wht is the best way to save this data from table to view

--
Randa Hesham
Software Developer

Twitter:@ro0oraa
FaceBook
:Randa Hisham

ٍ
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Randa Hesham
Software Developer

Twitter:@ro0oraa
FaceBook
:Randa Hisham

ٍ

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate