Wednesday, April 11, 2012

how to submit data in django's database

Hi all,

I have a question about how to enter data in django's database. I have the following Template, in which ' E ' is a variable that get the string:

<form action="." method="GET"><input type="text" name="E" style="width: 450px;height: 30px;" /></form>

This is my models.py in which I have a class named 'Company' and I want this variable 'E' be saved in 'Subject' :

class Company(models.Model):
    Subject = models.CharField(max_length=30)
    start_time = models.DateTimeField()
    end_time = models.DateTimeField()

    def __unicode__(self):
        return self.Subject

Then in views.py I wrote something like this to save the variable in Subject field, it's incomplete, and I want you to help me about it :

def Text_Box(request):
    T = request.GET.get(E,' ')
    if T:
       # I don't know how to make an object of class 'Company' so then I save ' T ' in Company.Subject
     else:
        return render_to_response("Base.html") # Base.html is my basic template file

I would really appreciate if you help me with it.
Thanks in advance.

Sophia



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ChZdnVfKiYIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate