Skip to main content

Posts

Showing posts with the label button

Django adding custom widget to Django Admin

Sometimes you need to get out of standard behaviour of your Django admin. It means expanding its functionality with custom things. In our case we have a model that we want to add a custom html element. Button that must load something via AJAX from another place to be exact. We have a typical Django polls application for simplicity. Here is its structure: First of all we need to create a structure. So here comes our model: # models.py from django.db import models class Poll (models.Model): question = models.CharField(max_length= 200 ) pub_date = models.DateTimeField( 'date published' ) We have to have our django application admin configuration to display that model: # admin.py from django.contrib import admin from polls.models import Poll admin.site.register(Poll) It will look in Django admin like so: You can see polls available here in admin. You can do all the typical things with Polls model. Add/Delete/Edit... Using standard D...

Django: How to add Google +1 button to your website.

What is Google +1 button? It's new Google social button. It's much similar to Facebook "Like" button. While available during one month it earned popularity that could compete with Facebook's social button. Corporation of Good knows what to do, so you probably want to have one on your website inline with Facebook's Like... Add Google +1 button to your site: - Open http://www.google.com/webmasters/+1/button/index.html and generate own button for your website. Google proposes HTML code like this: <html>   <head>     <title> +1 demo: Basic page </title>     <link rel = "canonical" href = "http://www.example.com" />     <script type = "text/javascript" src = "https://apis.google.com/js/plusone.js" >     </script>   </head>   <body>     <g:plusone></g:plusone>   </body> </html> It's quite simple, as you can see. And that's ...