Re: saving get objects to models

2013-01-22 Thread Satinderpal Singh
>> material = Material.objects.get(name=request.GET['material'])
>>
> I think this will help you :
> p = table(material =material, ...[other fields of table to be saved])
> p.save()

Thanks, this works for me.

> Here table is your table where you want object value to be saved.
> Hope this helps you.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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



Re: saving get objects to models

2013-01-22 Thread Sandeep kaur
On Tue, Jan 22, 2013 at 8:39 PM, Satinderpal Singh
 wrote:
> How to save the objects to models without using form. I tried to save
> the name object to the model, but unable to do so,
>
> material = Material.objects.get(name=request.GET['material'])
>
I think this will help you :
p = table(material =material, ...[other fields of table to be saved])
p.save()

Here table is your table where you want object value to be saved.
Hope this helps you.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

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



Re: saving get objects to models

2013-01-22 Thread Satinderpal Singh
Thanks, for this help

On Tue, Jan 22, 2013 at 9:34 PM, Bill Freeman  wrote:
> Forgive me if I am not being direct, but I'm not sure I understand your
> question.
You understand the problem very well.

> For the python statement that you include in your question to work, the
> following must be true:
>
> 1. There must be a query parameter on the url named "material".  e.g.;
> http://localhost:8000/myview/?material=admantium
> (Usually this would be provided using a form html tag, plus an input or
> select tag with name='material'.)
I have query parameter "material" in the url.

> 2. There must not be multiple material query parameters named "material" (or
> only the last will be used).


> 3. There must already be a row in the database's table for the Material
> model whose name field matches the value of the query ("admantium" in the
> case of the url in point #1), and only one row with that name.  (The row
> will be fetched from the database, and the values of its fields will be used
> to initialize attributes of the python class instance called 'material' in
> your sample.)
Yes, there is a row present in the database whose name field matches
to the value of query.

> None of this is what is known as "save"ing in the context of Django.  "save"
> is the transfer of data from the python class instance back to the database.
> If this is truly what you wish to do, modifying your existing row, you
> would, after the  statement you provided, assign new values to one or more
> of instance's attributes (e.g.; material.color = 'pink'), and then call
> material.save().
This is the thing i am asking for, i am unable to save the context of
Django. I used the logic given by you but it did not worked. How will
i save the value of material in the database name field.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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



Re: saving get objects to models

2013-01-22 Thread Bill Freeman
Forgive me if I am not being direct, but I'm not sure I understand your
question.

For the python statement that you include in your question to work, the
following must be true:

1. There must be a query parameter on the url named "material".  e.g.;
http://localhost:8000/myview/?material=admantium
(Usually this would be provided using a form html tag, plus an input or
select tag with name='material'.)

2. There must not be multiple material query parameters named "material"
(or only the last will be used).

3. There must already be a row in the database's table for the Material
model whose name field matches the value of the query ("admantium" in the
case of the url in point #1), and only one row with that name.  (The row
will be fetched from the database, and the values of its fields will be
used to initialize attributes of the python class instance called
'material' in your sample.)

None of this is what is known as "save"ing in the context of Django.
"save" is the transfer of data from the python class instance back to the
database.  If this is truly what you wish to do, modifying your existing
row, you would, after the  statement you provided, assign new values to one
or more of instance's attributes (e.g.; material.color = 'pink'), and then
call material.save().

Bill

On Tue, Jan 22, 2013 at 10:09 AM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> How to save the objects to models without using form. I tried to save
> the name object to the model, but unable to do so,
>
> material = Material.objects.get(name=request.GET['material'])
>
> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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