how to submit data in django's database

23 views
Skip to first unread message

Sophia

unread,
Apr 11, 2012, 12:54:06 PM4/11/12
to django...@googlegroups.com
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



Mario Gudelj

unread,
Apr 12, 2012, 8:50:17 AM4/12/12
to django...@googlegroups.com
Have you tried this?:

c = Company()
c.Subject = T
c.save()





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...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages