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


Download files

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

Source Distribution

django-mentions-0.2.tar.gz (15.2 kB view details)

Uploaded Source

File details

Details for the file django-mentions-0.2.tar.gz.

File metadata

  • Download URL: django-mentions-0.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-mentions-0.2.tar.gz
Algorithm Hash digest
SHA256 7911e36d65979dfb4fb14d2905d2bd6c956b9bc744a52d376a0a655e44e3b114
MD5 c23466fbab6ae139a718139f0037c8df
BLAKE2b-256 3f58c1a4315d7edc06a7dec179f4dea1931e13bd9131d587f7efbe2c43883ad3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page