Forms generated through admin in Django - python

I need to be able to create forms from admin panel. Process would look like this:
I click on "Add form" then I enter email to which the form should be sent and of course several fields (probably thanks to inlines) consisting of field name, type and if it is required. User should be able to view and fill the form and submit it and the data should be sent to the email given in admin.
Everything looks pretty straightforward but from my point of view it need some metaclass programming skills.
Could anyone point me to a goot form builder for Django or at least hand some tips about creating such thing? I found django-forms-builder but it is a bit too restricted imho.

I know this one's a few months old but I just though I'd post an update here anyway for anyone else that comes along.
django-forms-builder has just been rewritten to do exactly what you were looking for when you originally posted this question.
You can find the new version at http://github.com/stephenmcd/django-forms-builder or http://bitbucket.org/stephenmcd/django-forms-builder

There are many alternatives, although not many of them are actively maintained:
https://www.djangopackages.com/grids/g/form-builder/
If you want to have a full control of what's happening (change fields for your needs or add new ones, add captcha or honeypot, add custom handling of form data, use form wizards or even use your forms via web REST API), use django-fobi https://pypi.python.org/pypi/django-fobi

Related

Getting django accept phpBB users

My Problem is, I want to create a extra website on a phpBB forum to provide extra stuff and registration for meeting. No problem I know django and python, so this is no problem.
But I would be nice, if I could accept a session from a user or import the phpBB users so that they can login to my app.
I found django-phpBB, but I don't want to access the data. If I read correctly, my case is not the use case of django-phpBB.
Can anybody give me a good advice?

Option to add extra choices in django form

I am trying to create a model via a form that has multiple other models related to it. Say I have a model Publisher, then another model Article with a foreign key to Publisher. When creating a Publisher via a form, I want to create An article at the same time. I know how to do this via formsets. However, I don't know how to add a button that says add extra article at the same view, without having to be redirected to a new page and losing the old data since the form was not saved. What I want is when someone clicks add new article, for a new form for article to appear and for the user to add a new Article. Is this possible to be done in the same view in django, if so can someone give me and idea how to approach this?
I would show code or my attempts, but I am not sure how to even approach it.
This can only be done using JavaScript. The hard part is to have the management form sync up with the number of rows.
But there's two alternatives:
Semi-javascript (Mezzanine's approach): Generate a ton of rows in the formset and only show one empty. Upon the click of the "add another row" button, unhide the next one. This makes it easier to handle the management form as the unfilled extra's don't need any work.
No fix needed: Add as many rows as is humanly sane. In general, people don't need 40 rows, they get bored with filling out the form or worry that all that work is lost when the browser crashes.
Hope this helps you along. Good luck!

Django Editable Text Field

I've been able to easily create a list of editable items and manage them through the Django admin panel. That seems pretty simple and I have a good idea of how models work from other frameworks.
Although, I'm curious to know to know how I can make something as simple as editing a text area on a static site. Basically, I don't need to "add post" or anything of the sort. I just want to be able to edit a text area on a static site.
Any docs or examples?
I've been looking at packages such as django-flatblocks and chunks, these seem to possibly help with what I'd like to do. I'm just new to the Python world so some of this stuff is a little magic to me, especially involving the administration panel.
One thing that I realized is that these libraries (or apps in django?) seem to be super out of date, stemming back to the last commit being from 2012. Are these still commonly used?
Figured out a solution in case anyone is interested. I ended up using a Django application called django-generic-flatblocks which seems to provide me with what I need. Although, it's a bit strange as I had to replace all the text on my site with a gblock and then re-enter it all. Seems as if upon first creation of a block, it's empty so you essentially have to provide it with a value.
After that, if you log into the admin panel you're able to pull up the block and edit it. Alternatively, if you're logged into the Admin panel you're able to view your site and an edit tag is provided and you'll go directly to that block in the admin panel.
If anyone knows of anything which essentially allows me to define the text blocks up front in the admin panel then add the tags to the code, please lmk. I'd prefer to load all my content into the admin panel first and then just throw the tag into the code and have it display. That would save a lot of time in terms of having to copy the existing content, store it away, adding the tag, and then having to put it back in.
This seemed to be the only one of the recommended apps that worked for me. I tried to use Chunks because this really is only for title/text but on Django 1.11 it would freak out on me about not having South.db, which isn't even used.
https://github.com/bartTC/django-generic-flatblocks

Is it possible to have a form built by a user?

For example:
I have a user that wants to create a contact form for their personal website. They want three input type=text and one textarea and they specify a label and an name/id for them on my site. Then they can use this form on their site, but I will handle it on mine?
Is it possible for django to spit out custom forms specified by the user?
Edit: If django is too "locked down" what would you recommend I do? I would like to stay with python.
something like http://code.google.com/p/django-forms-builder or one of the million similar addins?
(made into answer at OP's request)
For this you would have some kind of editor that would create a html string. This string would be stored into your database and then upon request you would display it on the user's site.
The editor should be very strict into what it can add and what the user has control over, there are some javascript editors available that will be able to provide this functionality.
The only issue I can think of is that you may run into django escaping the form when displayed to the page.

Django FormPreview - What is it for?

While looking across the Django documentation, I came across the FormPreview.
The description says this:
Django comes with an optional “form preview” application that helps automate the following workflow:
“Display an HTML form, force a preview, then do something with the submission.”
What is meant by "force a preview"? What would you use this feature for an in application?
To force a preview means the users are forced to see the value they have inserted on the form input fields, before django actually saves it to the database.
One example is django comment system, which enforce the users to take a look at the comment they have written before django actually saves it to the database. You would see that the users are redirected to another page to take a look at their comment, and after that there is a submit button to actually save the comment.
I think they mean (I use django but I didn't know of this until now..) that you can let people write, for example in a textarea box like I'm doing right now. After the user submits it the system would preview it to the user and give him the chance to read and edit what he submitted, before it being submitted again all the way to the database.

Categories