forked from ivirabyan/django-mentions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
62 lines (48 loc) · 1.3 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
=======
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 }}