Skip to main content

Facebook-like mentions for Django

Project description

=======
django-mentions
=======

Facebook-like mentions for Django
-----------------------------------------------------

Installation
""""""""""""
Add aplication to INSTALLED_APPS in **settings.py**:
::

INSTALLED_APPS = (
...,
'mentions',
)

Add app urls to your **urls.py**:
::

urlpatterns = patterns('',
...
url(r'^mentions/', include('mentions.urls')),
)

Implement a mention provider:
::

from mentions.providers import Provider

class UserProvider(Provider):
model = User

def get_title(self, obj):
return obj.username

def search(self, request, term):
return self.get_queryset().filter(username__istartswith=term)

Add this provider to your **settings.py**:
::
MENTIONS_PROVIDERS = {
# You can put your provider anywhere you want
'default': [
'accounts.mentions.UserProvider'
]
}

Use `mentions.forms.MentionTextarea` widget instead of the default one:
::
from mentions.forms import MentionTextarea

class PostForm(forms.ModelForm):
class Meta:
model = Post
widgets = {
'text': MentionTextarea
}

To urlize mentions in your templates, use `urlize_mentions` filter:
::
{{ post.text|urlize_mentions }}

Project details


Release history Release notifications

This version
History Node

0.2

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-mentions-0.2.tar.gz (15.2 kB) Copy SHA256 hash SHA256 Source None Dec 30, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page