I need to make objects editable in frontend by clicking on it and enable a form field to edit the text. i.e. in a ToDo-list which tasks can be edited by clicking on the task like shown in the following graphics:
I am working with Django 2.x and unfortunately, I'm a little inexperienced.
Is it a good practice to realize this with REST API and/or Angular/React?
I would be glad about a few experiences, how something is feasible.
I have found a good solution to implement the desired functionality with Jeditable
https://github.com/NicolasCARPi/jquery_jeditable
Related
I want to allow the users of a django-CMS to edit the background image in one of my CMS_TEMPLATES using the filer admin. How can I achieve this in a clean way, but with minimum of code and database tables?
My current solution is to (mis-)use the cmsplugin_filer_file by writing a custom template for it. The disadvantage is that I'll maybe want to use this plugin in a different way one day, and I think one cannot have several templates for one plugin.
A cleaner alternative would be to write a custom cmsplugin with a model containing a FilerFileField and nothing else. But this will require more lines of code and will create a new database table.
Is there a better solution which I didn't think of yet?
I hope, this question can be answered, not just discussed...
Maybe have a look at page extensions. This a new 3.0 feature:
http://django-cms.readthedocs.org/en/develop/extending_cms/extending_page_title.html
I am attempting to write a Redmine plugin which further filters textilizable fields (issue description, updates, wiki content, etc.).
I've leafed around the plugin documentation but did not really find a good place to start. The view hooks seem to allow you to inject content at pre-defined injection points. Nothing really stood out toward creating a filter for textilizable content.
The most straightforward way is to hack the code in application_helper.rb and create your own filter function along the same lines of the :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links. However, I do not see a good way of inserting that in a plugin without monkey patching the entirety of textilizable(*args).
Am I missing something obvious here?
One possible way, here: http://www.redmine.org/boards/3/topics/33949
This board topic mentions the caveats associated with view hooks (mentioned above) and offers a workaround or two that lets you change content by overriding views.
Personally I don't think Django's built-in widget for ManyToManyField relationship is particularly good. Especially when it comes down to use it on an iPad, the widget is neither intuitive nor practical (you have no ctrl button to hold down to multi select).
So I am battling this issue now for one week, trying to make a formset with forms that include each a dropdown.
My attempts to achieve the solution above, have also been fruitless so far.
So I thought maybe its a good time to take a step back and ask the community:
What would you do in my shoes? If you were given a requirement like this, how would you replace the M2M widget? What options do I have?
I just found out about the admin M2M widget according to this question on Stackoverflow.
django.contrib.admin.widgets.FilteredSelectMultiple
It is a bit big and not very pretty, but would do the job.
I have found this tutorial and followed every step. But the widget is still showing as a plain M2M widget instead of the admin one. The css and js are loaded correctly (no indication of 404) but still the old widget shows up.
Many Thanks,
Try using chosen library. You can download it from here: http://harvesthq.github.com/chosen/.
To integrate it with django try django-chosen application. You could install it from PIP or directly download sources from github.
I have a small blog app I have built using Django 1.4 and recently, I have been learning "bits and pieces" of html5 and css3. I am about the start transitioning my site to html5/css3 and I was wondering if Django widgets support html5(?)
My blog is nothing special - a few forms, a few tables etc.. For example when I do,
{{form_as_p}}
I was wondering if django would generate the required html5 markup(?) I read the docs, and it says the admin pages support html5, but I could not find any docs for regular apps.
If html5 is not supported by Django, what is the best way going about achieving this?
Thanks for your time.
Django's form output is XHTML. Django does not snip with support for the new HTML5 input types such as number, email, url, etc but it is not difficult to add them. See https://code.djangoproject.com/ticket/16630 or https://github.com/rhec/django-html5 That being said I don't know any place where Django generates markup that is invalid for HTML5.
"If html5 is not supported by Django, what is the best way going about achieving this?"
I have been trying a monkeypatch approach with very encouraging results so far, the big bonus for me is that there is no need to change your existing code, or for modifying third party apps, or Django admin. This keeps things very clean and central and there is no need for hairy and repetitive admin.site.register(...)/admin.site.register(...).
https://github.com/danielsokolowski/django-html5monkeypatch
I'm looking at porting a custom-written PHP CMS into Django. One of the features the CMS currently has is an image upload function. I write an article, tag it with information, then choose a photo for it. If the system has any photos which have been added to articles with tags in common with the new one, it will suggest the photo for that article too. If there are no matches then a new image can be added.
In case this doesn't make sense, let's say I tag an article as Bruce Springsteen, The Beatles and Led Zeppelin. Next time I add an article with the tag The Beatles, it should suggest I use the image added for the first article.
What would be the best Django-applicable way to implement this? I've looked at the Photologue app and have integrated it, and I know it has tagging support (the problem here is that I'm using django-taggit, whereas Photologue supports django-tagging). One approach could be simply building it myself -- when a user uploads an article, I run a hook after they save it to associate the tags with the image. I'm just not sure how to then autosuggest an image in the admin tools based on that info.
Any ideas/approaches greatly appreciated.
This is almost certainly something you're going to have to build yourself. Django has a moderate number of libraries out there (that you've clearly already found). Unlike other solutions, it doesn't have a lot of things that get you 100% to your desired solution (whereas something like Drupal might get you 100% of the way there).
What you will probably need to do (at a high level) is something like this:
Create an AJAX view that takes the current tags as an argument and does a query on the existing posts to see what tags match and returns images from those posts.
Use jQuery/javascript on your view to call your AJAX view on the page as tags are added
Use jQuery to update a <div> on your page and show all the images that your view returned
Here is a similar example that might help get you started.
You might look into django-ajax as a helper library for your requests, but it definitely isn't necessary.
The hook between the your image module and any other django module can be implemented using django's contenttypes framework which also provides some useful instance methods for returning related/hooked objects.