LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-11-2011, 05:24 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
django: Is it possible to create a form "on the fly"?


Hi!

I'm wondering if it's possible to create a form on the fly? I mean, instead of having a class extend a form defining the fields in the form, is it possible to create it manually so that the form code can be retrieved for an HTML page and checked on submittal?
 
Old 10-13-2011, 03:24 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Since this has gone unanswered for a few days, I'll take a shot, with the proviso that I'm a full-on Django newbie.

Since you can return anything you want as an HttpResponse object in your views.py module, I'll say 'sure'. Whatever HTML your view class can generate should work. Whether this is considered good form (bad pun intended) is another matter. But really, you can also use iteration in templates, so I don't understand why that wouldn't be just as good; probably even better.

--- rod.
 
Old 10-13-2011, 03:32 PM   #3
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,684

Rep: Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441Reputation: 1441
I'm going to say yes, even though I don't understand the following:

Quote:
is it possible to create it manually so that the form code can be retrieved for an HTML page and checked on submittal?
You can obviously create a form without using the Form class (just put the form and its fields in a template). You also have the freedom to return any string you want to from a Django view. And if you're summitting the form via POST, then the POST data will be available to your views.

Last edited by dugan; 10-13-2011 at 03:41 PM.
 
Old 10-13-2011, 03:42 PM   #4
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Original Poster
Rep: Reputation: 83
I mean using a form to create the html code for the given for and be able to use the form to do the checks when the form is "POSTED", so to speak. And it can be done... or at least, it has worked for me. Check http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/
 
  


Reply

Tags
django, form, hack, python


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i create a global variable called "dogpatch" with a value of "woof" earthdog Linux - Newbie 9 12-15-2009 01:03 AM
which dvd burner has the "copy on the fly" feature? baambooli Linux - Software 1 08-12-2009 01:39 AM
LXer: "You Know Linux? Marry Me!" Doesn't Fly LXer Syndicated Linux News 1 08-18-2007 09:10 AM
LXer: Linux "phrase book" offers on-the-fly CLI tips LXer Syndicated Linux News 0 07-14-2006 07:54 PM
Hard drive lose dma "on the fly" Hammett Linux - Hardware 4 08-23-2004 01:38 PM


All times are GMT -5. The time now is 09:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration