Gallery in Photologue can have only one Photo - python

after I put the photologue on the server, I have no issue with uploading photos.
the issue is when I am creating a Gallery from the admin site, I can choose only one photo to be attached to the Gallery. even if I selected many photos, one of them will be linked to the Gallery only.
The only way to add photos to a gallery is by adding them manually to photologue_gallery_photos table in the database :(
anyone kows how to solve it?

I had exactly the same problem. I suspected some problem with django-sortedm2m package. To associate photo to gallery, it was using SortedManyToMany() from sortedm2m package. For some reason, the admin widget associated with this package did not function well. (I tried Firefox, Chrome and safari browser).
I actually did not care for the order of photos getting uploaded to Gallery, so I simply replaced that function call with Django's ManyToManyField(). Also, I noticed that SortedManyToMany('Photo') was called with constant string Photo. Instead it should be called with SortedManyToMany(Photo) to identify Photo class. Although it did not resolve my problem entirely. So I used default ManyToMany field and it is showing all the photos from Gallery.

I guess your problem is solved by now, but just in case.. I had the same problem. Looking around in the logs, I found it was caused by me not having consolidated the static files from sortedm2m with the rest of my static files (hence the widget was not working properly).

Make sure sortedm2m is in INSTALLED_APPS in addition to photologue; merely duplicating any sortedm2m templates alone will not suffice.
Installation & configuration — django-photologue 3.6 documentation

Related

In Django, how can I load images based on screen size?

Apologies for not having any specific broken code here. I already know that what I would try won't work from a different question here, and I have a vague idea of something that might work but is likely not the best way to do it.
I'm building a website for a photographer, so it's important that I'm loading the best looking photos that the user is capable of seeing. The starting file size for the images is a few MB, but the model uses Pillow to save down-scaled copies. There are times when I want a full-screen image at high resolution, but I want to serve a smaller image if the user is on mobile, for example.
What I would have done was load the images from CSS background-image with media queries, but I understand that I can't use template tags in CSS.
My next guess would be to build two separate versions of each template and have the views render a different template based on the user-agent of the request, but that strikes me as probably not a great solution to put that much trust in the request headers, and the functionality could break as easily as a new browser release. There's a better way, right?
Why not CSS? - In this case, the images are dynamic content. The photographer doesn't know web development and I'm not going to update the site for him every time he adds or removes images or blog posts, etc, so the site is a lite CMS. He can freely add or remove images from galleries, etc. The django view/template then find and serve the images from the query set. Instead of referring to specific images and their specific smaller versions, I'm asking the server to serve whatever images currently belong to a specific queryset in the database, and serve either the smaller or larger versions of the images, and to do so with the explicit goal of not having the user download resolution that they can't see.

Using flask flash pushes down all the contents

I m working on a project.I am using Flask.Flask flash is gives a message but pushes all the contents down.Can anyone suggest a better method to give responsive messages similar to session.flash in web2py
You need to make changes to your css. Somewhere in your css, you must have a .flashes class, change its properties.
If class flashes is not present in css, define it
and then add position:absolute to it.

Make a plot visible in IE

I've been making plots in Bokeh, they work fine in Chrome, but I just get blank pages in IE. I thought this was because my company uses IE8 by default, but we've now been upgraded to IE11 and I see the same problem.
The IE debug console reports that the page targets document mode 7, so it may be an issue with the metadata in the page header.
Is there a way to make Bokeh output plots with the correct metadata for IE?
I ran into a similar issue with a Bokeh figure at work not showing in Internet Explorer, but the figure worked fine in other browsers.
For me the problem seemed to be that intranet sites were shown in Compatability View (I must admit I don't know what Compatability View means...). The fix was to choose the options icon in the upper right corner, then Compatibility View Settings and then remove the checkmark at Display intranet sites in Compatibility View. After close and reload the figure appeared.
We regularly test on IE before release, so I am not sure what the issue could be. You can definitely get just the plot components using various functions in bokeh.embed and template them into what whatever larger documents you like, but perhaps the default template needs updating or tweaking. I don't know what "document mode 7" is, but some of the other devs might be more familiar with IE and can help investigate. In any case I encourage you to make a proper issue not the GitHub issue tracker:
https://github.com/bokeh/bokeh/issues
Also had this issue with IE11.
I fixed it by removing webgl=True option from bokeh.plotting.figure() call.
cf. [http://docs.bokeh.org/en/0.11.1/docs/user_guide/webgl.html]

update text within html

So I have a python webapp on Google App Engine and am using the jinja2 template engine. I have a lot of text on the site that I want to update regularly, such as news sections and updates about the site.
What is the most efficient way to go about doing this? Clearly the simplest short-term solution and what I am currently doing is just to change the HTML but I would like to give others access to this without giving them access to the server side of things.
Should I just bite the bullet and write a interface on an admin page that allows users to edit it and then the server takes this and renders it in the News section? Any suggestions or tips would be great!
What you are thinking about, and moving toward (whether you know it or not) is called a content management system.
Most of them store content in a database and provide a user interface to allow editing it, just as you're designing.
Perhaps you could use off-the-shelf parts? I don't know exactly which ones are appengine-based, but this is a very common task and I'm sure you'll save time by using others' work.
I have created a very basic jinja CMS to maintain Jinja (page) blocks. You can find it here: https://codereview.stackexchange.com/questions/5965/review-request-jinja-cms-for-energiekantoor-nl-on-google-app-engine

Django reportlab - Print current page (admin console) to PDF

What I am trying to accomplish is to allow users to view information in the django admin console and allow them to save and print out a PDF of the information infront of them based upon how ever they sorted/filtered the data.
I have seen a lot of documentation on report lab but mostly for just drawing lines and what not. How can I simply output the admin results to a PDF? If that is even possible. I am open to other suggestions if report lab is not the ideal way to get this done.
Thanks in advance.
Better use some kind of html2pdf because you already have html there.
If html2pdf doesn't do what you need, you can do everything you want to do with ReportLab. Have a look at the ReportLab manual, in particular the parts on Platypus. This is a part of the ReportLab library that allows you to build PDFs out of objects representing page parts (paragraphs, tables, frames, layouts, etc.).

Categories

Resources