FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
django-basic-apps/basic/messages/forms.py at master · libinpython/django-basic-apps · GitHub
libinpython
django-basic-apps
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
django-basic-apps
/
basic
/
messages
/
forms.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (17 loc) · 721 Bytes
Breadcrumbs
django-basic-apps
/
basic
/
messages
/
forms.py
Copy path
File metadata and controls
22 lines (17 loc) · 721 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from
django
import
forms
from
django
.
contrib
.
auth
.
models
import
User
from
basic
.
messages
.
models
import
Message
class
MessageForm
(
forms
.
ModelForm
):
to_user
=
forms
.
CharField
()
class
Meta
:
model
=
Message
exclude
=
(
'to_status'
,
'from_status'
,
'from_user'
,
'object_id'
,
'content_type'
)
def
clean_to_user
(
self
):
if
self
.
cleaned_data
[
'to_user'
]:
try
:
user
=
User
.
objects
.
get
(
username
=
self
.
cleaned_data
[
'to_user'
])
self
.
cleaned_data
[
'to_user'
]
=
user
return
self
.
cleaned_data
[
'to_user'
]
except
User
.
DoesNotExist
:
pass
raise
forms
.
ValidationError
(
u'There are no users with this username.'
)
Back
|
FazBrowse Home
|
New Git URL