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.

Reply via email to