Save keywords / meta title in Mezzanine - django

I've recently started tampering with Mezzanine and I am trying to add 2 new fields to the Blog Post admin -- keywords, and meta title.
I did it by editing my admin.py file and adding the following:
from mezzanine.blog.admin import BlogPostAdmin
from mezzanine.generic.models import Keyword, AssignedKeyword
BlogPostAdmin.fieldsets[0][1]["fields"].extend(["keywords"])
BlogPostAdmin.fieldsets[0][1]["fields"].extend(["_meta_title"])
admin.site.register(Keyword)
admin.site.register(AssignedKeyword)
I see the fields in the blog post manager, but when I edit them specific to a blog post, they don't save to that post. However, if I am adding keywords, the keywords get saved to the overall site keywords (generic_keyword table).
Is there any way to make them also update the blog post such that _meta_title and keywords_string gets updated in blog_blogpost? Thanks for any help.
EDIT: After looking into this further, it doesn't seem that I need to do anything to get the "Meta Data" section to be expandable. However, in my copy, it cannot be expanded. Is there any particular reason for this?

The answer above is a bit incomplete, and will be misleading for anyone who comes across the same problem.
My guess is that at some point you copied the admin's base_site.html template into your project, from an older version of Mezzanine. You've then later upgraded to a newer version of Mezzanine, which refers to an upgraded version of chosen - you can see the commit from 3 months ago here where that occurred here: https://github.com/stephenmcd/mezzanine/commit/f4e33282eaac44ef8ebbadb9b0157d910c67973a

If anyone experiences this issue, check your javascript console. In my case, for whatever reason, the Admin section was trying to load mezzanine/chosen/chosen-0.9.12.jquery.js which doesn't exist. I edited blog/templates/admin/base_site.html and updated it to mezzanine/chosen/chosen.jquery.js and the Meta Data section became expandable/collapsible again.

Related

Is there an equivalent of 'list_editable' for FileFields in django?

I'm making a website with django where you can basically upload a file to the django admin and download it whenever you need to view it. Very simple (making it for my dad which wants to organize his excel files for his work).
This is the problem, I hard coded the download path to the file I uploaded, which makes me have to modify the path every time I upload a new file with the same name (since django adds a random string of digits and characters every time you upload a file with the same name as before). What i'm currently doing is really inefficient, and would like to change that as soon as possible.
My idea is to make the FileField name editable in the django admin. I've come across this:
list_editable = ['asd'].
I thought that might work and so I tried it. The results were interesting. I immediately saw a 'Save' button on the bottom of the admin site, which wasn't there before. But I still couldn't edit the FileField. I've searched this on multiple forums, the django documentation and more forums, only to not find anything useful.
This is a picture of how the admin page looks when I added the list_editable to my FileField.
So, I decided to look for an equivalent to see if that works. Again, I searched on multiple forums, but still found nothing.
Any type of answer or recommendation is very much appreciated.
Thanks in advance!!

django approve or reject for everyone field in object

I am looking for a package or hints on how to track each field and the ability to accept or reject editing
i using Django 1.11 and python3
Package like:
django_monitor not working
django_approve not working
It sounds like django-moderation should fit you need. I haven't used it personally, but the docs mention that it's possible to have changes displayed only after a moderator accepts them, and there is also an option (keep_history) to maintain the history of the changes made to a model.

django-tinymce modern theme

I'm having issues getting the modern theme to work with django-tinymce. Both the simple and the advanced themes render correctly, but when I switch to the modern theme nothing renders and I get a 404 error for /static/tiny_mce/themes/modern/editor_template.js in the console
I am attempting to do all of this in the django admin. The error is coming from /static/tiny_mce/tiny_mce.js which is interesting because I don't have anything installed in that directory. I'm using /static/js/tinymce as my TINYMCE_JS_ROOT in settings.py. When switching between simple and advanced theme, everything works correctly.
I've tried to copy a version of editor_template.js in the exact location it's looking, but I still get the 404. It's like it wipes out /static/tiny_mce if it exists and replaces it with something, but I can't figure out how/where it's getting that from.
I'm using an install of TinyMCE 4.1.3 from http://www.tinymce.com/download/download.php and django 1.6.5
I've been struggling with TinyMCE recently, as well. I'm using TinyMCE v4 and Django 1.6. I went down the django-tinymce/django-flatpages-tinymce route because I had these working on another project. Some how it wasn't working for this new project. I did some research and decided to just go straight TinyMCE, no Django applications (eg, no django-tinymce or django-flatpages-tinymce).
This method cuts down on all configuration in Django, and it can be completely handled within the tinymce.init call. I found this much easier than dealing with Django's settings files, overriding models, etc. Just simply find the template you want TinyMCE to spice up and add the init call there.
The example here for full featured example really helped me:
http://www.tinymce.com/tryit/full.php
This use the modern theme...
I simply added this to whichever change_form.html template for whatever model I was needing the rich editor. For instance for flatpages:
admin/flatpages/flatpage/change_form.html
Or custom model in app:
admin/custom_app/model_name/change_form.html
I know this is exactly an answer to your question, but I think it's worth thinking about and might help you ultimately get what you need.
Also, I should note, it looks like only modern theme is available for TinyMCE v4:
http://www.tinymce.com/wiki.php/Tutorial:Migration_guide_from_3.x

django on apache - admin page links are VISIBLE but not CLICKABLE

I have just deployed a django site, and upon changing the value my DEBUG variable to 'False' causes my admin page links to change from active links to simple text.
An attempt to go directly to what I know should be the URL causes a 'TemplateDoesNotExist'.
I am sure it's not a permissions issue with Apache, I feel it is something to do with my admin configuration though I have no idea what.
I figured it out. Here is a reference for anyone else who might find themselves with this problem.
I was using what must be a deprecated method of defining my Admin models - I put them all in models.py, instead of creating a separate admin.py file for each application.
When learning django, there are plenty of tutorials floating around that recommend or give examples that use this method. Apparently this is no longer a good idea (at least not as of Django 1.4). It could probably be wrangled into working with some template hacking, but it is is probably cleaner and definitely simpler to just follow the latest conventions and create the admin.py file.
I thought I was saving time by just cramming it all into one file "for now" but without some of the magical debug-only template loading, this solution failed.
Hope this saves someone some frustration!
I know this question's been already solved.
But in my case, coming from django 1.7 to a server that runs django 1.6, I had to add
admin.auto_discover()
to my urls.py.
Well, I had added this line to the end of urls.py and django admin was all characters !
Moving it to top up the file, above definition of urlpatterns, fixed the issue.
Hope this helps :)

Grappelli admin "change_list" columns are not sortable

SOLVED: Has been a bug in grappelli-safe, which is the grappelli fork used for Mezzanine. Should be solved by now.
I have never used grappelli before switching to Mezzanine, so i do not know if this is standard behaviour, but i would be very surprised.
This is what happened: after installing Mezzanine everything worked fine, and Grappelli skinned my admin nicely. A few hours later i realized i could not use the column header row to sort objects by the value of that row. The row headers are only links, that reload the page. I'm pretty sure that these links should be overridden by some javascript to allow sorting, but there is no 404 or other error in retrieving the static files.
If someone could confirm that i'm really hunting a bug that would be great. I would hate to use hours for tracking something that is just normal behaviour. And if someone else knows how to fix that, or what script would be responsible for overriding the links, that would be even better.
I hate not to be more specific, but that's all i have right now... :(
Ah, one more thing:
A bit more specific at least: What i want to do is to click on "Status" to sort by the status column. But "Status" is a link to the current page, and therefore just reloads the page.
This just happened to me: It can also be caused by using django 1.4 with grappelli 2.3.8 (both current in pipi)
See this thread for details:
https://groups.google.com/forum/?fromgroups#!topic/django-grappelli/