I'm using the Mailgun unsubscribe handling. I'd like to be able modify the mailgun generated "Unsubscribe" and "You have unsubscribed" pages. If there is no way to modify these pages, is there a way to wrap them with header / footer to add some branding?
Unfortunately, unless you handle the unsubscribes on your server, there is no way to customise those pages!
Hey You can actually handle it yourself. What your saying is possible however according to mail-gun support the urls are never front facing meaning in your html you would have to do something like this:
<br>
Want to change how you receive these emails?<br>
<a href=%mailing_list_unsubscribe_url% target="_blank">Stop receiving emails
from us</a><br>
According to them this should work the same as there methods. if you do not want to use the unsubscribe mailing list then use another one there are 3 found here
Related
Is there any magic why to do this in admin panel of django?
Let me know
Off the top of my head, you could use JS to grab the popup link and load the HTML in a div on the page. But that means you need to override the admin template. This QA should be helpful.
It also means you need to capture the saving of the new house. So, when someone presses save, depending on the response, the div either closes or shows the errors WITHOUT refreshing th page. I'm not sure but I think you'll also need to override the admin view that does this to send back json responses.
OR
You could use JS to mute that link and call up your own url, which would allow you to create your own view with your own custom form that does this. This would give you a bit more control without having to hack away at the Admin functionality.
e.g /house/ajax_add
You'll need to refresh the options in the House dropdown though. So I don't think you can avoid extending the template, now that I think about it.
It seems like a lot of trouble, really. No magic way that I know of, but it's possible.
To avoid popups, you might want to look at https://github.com/FZambia/django-fm:
Django-fm allows to create AJAX forms for creating, editing, deleting
objects in Django. This is a very personalized approach to quickly
build admin-like interfaces.
A live example can be found on http://djangofm.herokuapp.com/.
I'm not sure how this integrates with the current admin site, but with some changes it should not be hard.
I'm building a light news extension which should allow sending news via email.
How could I add a custom action for email sending like in the picture?
Thank you.
Take a look in the source, there is a hook that allow you to modify this bar to add or remove buttons.
http://wiki.typo3.org/Hook_programming
You can find good example of hook using in ext:news. Look for InlineElementHook class.
For example: renderForeignRecordHeaderControl_preProcess or _postProcess
I have a Django-powered WebApp that occasionally needs to send pretty HTML emails to my users.
I'm learning how to send HTML emails using Django. Here are the instructions I'm following. They are quite simple and good: http://www.djangofoo.com/250/sending-html-email
By following these instructions I'm able to send HTML emails. However, the emails I want to send should share the styles and look-and-feel of my webApp of course. Each Django template on my website includes a bunch of CSS at the top that ensures a consistent look. However, when I simply send that template as and HTML emails, the styles do not kick in in the email. Does CSS not work while sending HTML emails through Django?? Do I need to manually and explicitly set the fonts, colors, bold, italics, of each element in the HTML template I would like to use for the email? How do other people do this?
CSS is very difficult to get right with html emails... The general rule is to use inline styles and try to stay as basic as possible.
This SO question has some good resources in it for guidance on designing html emails.
Instead of manually setting all styles in the email, I tend to use the same CSS styles as the site if I want emails that should be pretty. However, emails need the styles inlined, and for that I use the inlinestyler module, which will take the HTML and the CSS files and set the relevant styles inline before sending the email.
There are still some things to think about, if you are careless you get gigantic emails because you use big style settings everywhere, and many email clients will not do positioning correctly etc. so you may have to make custom CSS styles for your emails anyway. But even if you do, inlinestyler is useful, as you get much more maintainable emails with the CSS and the HTML separate.
CSS is supported by some email clients, and not supported by others. Some clients support inline styles and others do not. You can see a fairly verbose list here. Most of what can be done with HTML/CSS can be done with inline styles and (gasp) table layouts, but some of it is simply impossible. Tools like the one #Lennart mentioned are invaluable, but "just inline everything" doesn't accommodate for a number of issues. (Pseudo classes comes to mind as a major point (a:hover is supported by Outlook, while .classname:hover is not), as does background image (there is a hack to make that work though)).
I guess that my basic point is that you can try to shortcut the process by using inlinestyler or similar, but you are going to need to keep a separate set of files, and you'll definitely be doing a series of manual tweaks.
I think you will find that email clients will not retrieve the css.
Instead, in your email, put the contents of your CSS files directly into the email, with <style> and </style> around it.
I've implemented a notification bar using django.contrib.messages. Now, I want to make extended use of it, e.g. to display a "Welcome back" or "Logout successful" messages. However, I prefer to use builtin views for basic actions, so I use django.contrib.auth.views.logout_then_login for logging out and django.contrib.auth.views.login for logging in. Therefore, there isn't a single place where I could insert my messages.success(...), since those views are not mine.
Is there an elegant way to add those messages nevertheless without copying or overwriting views?
Signals are your friends. See in particular the login and logout signals.
Forgive this newbie (and possibly subjective - I don't know) question.
I want to add a REST API to my site. For example, I have a URL that is /post/ that shows all posts, and I'd like to give users a way to get all posts back in JSON.
Is is better to:
define a new API URL structure (e.g. /api/rest/post/ to return all posts in JSON)
use the existing URL structure, and allow users simply to append /json/ on the end of each URL to get JSON objects back? (e.g. /post/json/ to return all posts in JSON)
If the latter, then is there a standard way to implement it, in terms of views? Should I simply add an optional json parameter to all my views?
Thank you for your advice.
Take a look at Piston, which is a Django plugin to handle REST APIs.
Listen to the previous commenter's advise. But in particular that's probably better to use new API URL structure (/api/rest/post/ as you've said). Separating totally different kinds of functionality is always good for your project. In other words, you can place your API documentation at /api/docs/, and it will look natural. If you use same URL structure, it will be not so obvious where to place your docs.
The answer is of course also subjective.