I have a Django and i want to create CRM system, allowing users to view, add, delete and edit data in a front-end. I found nice module, named django-tables2, which allows displaying nice tables of my data:
django-tables2 turns data into HTML tables. Features:
Pagination Ordering Extendable Class based view Supports for queryset
and list data Themes
So my question is what is the best way to make front-end editing with this tables?
For example: i want to make records from table be selectable with checkboxes and then i want them to be deletable and editable, like in django built-in admin. In other words: i need some tool like django-admin but in my front-end (in my template).
So do i need to write js to handle user clicks on table records and point this actions to my urls/views or there is a better way?Hope this question will help not only my but anyone who planning to became frontend-ninja, THANKS!
I think you should take a look at Swampdragon and Angular. They might integrate nicely with django-tables2. You can always just write the table with Angular.
Related
I am trying to create a simple, Django-based To-do web app. Each task in the app will be linked to tags.
I can achieve the above by creating models for both the tasks and the tags with many:many relationship. When I create the form for user to create new tasks (using ModelForm), they are also offered up a a way to multi-select tags.
All of the above is fine. However, I am trying to figure out a way
to give the user the ability to ‘create’ new tags when they’re creating new tasks as well.
Ability for user to enter comma separated tags that get added to db as individual ‘tag’ objects.
Can this also be done while retaining the choice for users to select from existing tags?
How do I achieve any or all of this? Any help would be much appreciated. Thanks!
1- you need a button like + in django admin when user click on that show dropdown or something and get tags from user and update your tag list in the tasks form ( with ajax or something else )
2- i think this is can archieve with frontend 🤔 search for select2 library.
But if you want user send tag1, tag2, tag3 you can use .split(",") in your view to get each tag and save on db.
I want to dynamically create multiple dropbox fields as I input the number of fields to be created.
For instance, there are 2 fields:
integer input field
dropdown menu
so when I input(let's say "4" in field 1) then 4 dropdowns should be created.
How should it be done? And upon submitting the form the same will be stored as a list in a database (flask is used at the backend).
Please guide.
Thanks in advance.
Flask is rather lightweight framework so to create fields dynamically use Javascript. Note nowadays its preferred to develop websites using some advanced JS library or 'framework' JQuery, vue, react etc. On backend you create a controller to save the data. Start with going though a tutorial to understand the procedure. https://www.youtube.com/watch?v=6N4OmsfwfdU . If you use WTF find a tutorial or discussion specific to WTF.
I am new in django (and python as well).
I want to have a dependent select field for state and city in admin . I know the feature Grouped Selects in django smart selects can do this. But this method render the options from the database which is not what I looking for.
I have the dependent data from the external source (json format), and using javascript to populate the regarding data.
So, how do I create the select field and add a class to it (for js selector)?
should I create a empty text field and using js to convert it to select field?
Thanks
I would consider using django autocomplete light, it is a fairly solid select-field chaining tool that is good for both model relationships and remote data sources.
This is a link to the documentation for the remote data integration.
http://django-autocomplete-light.readthedocs.org/en/latest/remote.html
I've been searching stack overflow and google for a solution for over an hour now, and I can't seem to find something that, in my opinion, should be easy to obtain (as it's a common use case).
I've checked this thread, and a few others, but I haven't been able to find a real, easy solution:
Django modelform: is inline adding related model possible?
Anyway, say I have a model with three related entities, two foreign keys and a many-to-many related class. Now, I have a ModelForm which displays these in comboboxes and lists, but what I need is that "+" button next to these elements (as seen in the admin interface).
I want the plus to take me to a new form, for that particular entity, allow me to submit the new information, create the database entry, take me back to my original form and have the newly added entity selected in the combobox. I'm really hoping the django ModelForm Meta class has an attribute that I can't seem to find which enables exactly this.
This isn't really a django question.
This has to do with presentation of a particular widget in an html document, and that is governed by either the HTML markup, CSS, or javascript.
Django is a server side application and is primarily responsible for creating a valid http response and receiving a valid http request (of course, there is a lot that happens in the interim and that is why django is so big) but it's not a "one toolkit to kill them all" app.
I think you want to look at bootstrap: http://getbootstrap.com/
Jquery UI: http://jqueryui.com/
Or some combination of the two.
You can also just mark up the document yourself with a stock img or something.
However, if you want to do it exactly how the admin does it, just go into django.contrib.admin and examin the code to figure out how the django developers did it. I believe they are just using Jquery UI and some manual markup to accomplish that.
I have been trying to get my head around Django over the last week or two. Its slowly starting to make some sense and I am really liking it.
My goal is to replace a fairly messy excel spreadsheet with a database and frontend for my users. This would involve pulling the data out of a table, presenting it in a web tabular format, and allowing changes to be made through text fields and drop down menus, with a simple update button that will update all changes to the DB.
My question is, will the built in Django Forms functionality be the best solution? Or would I create some sort of for loop for my objects and wrap them around html form syntax in my template? I'm just not too sure how to approach the solution.
Apologies if this seems like an simple question, I just feel like there is maybe a few ways to do it but maybe there is one perfect way.
Thanks
The fastest way not to implement you own pages and to have a tabular view of your data is to use the django's built-in admin interface. It gives you sorting, filtering and search functionality and quick to start. You just need to define your models in models.py and setup the admin pages as described in the docs.
Normally the admin page is not used as a representation to users or customers but in the case you described it seems a clean and quick choice.
Exporting the excel sheet in Django and have the them rendered as text fields , is not as easy as 2 step process.
you need to know how Django works.
First you need to export the data in mysql in database using either some language or some ready made tools.
Then you need to make a Model for that table and then you can use Django admin to edit them