This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogoutView(RedirectView): | |
""" | |
Provides users the ability to logout | |
""" | |
url = '/login' | |
def get(self, request, *args, **kwargs): | |
auth.logout(request) | |
messages.success(request, 'You are now logged out') | |
return super(LogoutView, self).get(request, *args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Login(FormView): | |
""" | |
Provides the ability to login as a user with a username and password | |
""" | |
success_url = '/' | |
form_class = UserLoginForm | |
template_name = 'accounts/form.html' | |
extra_context = { | |
'title': 'Login' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Register(CreateView): | |
model = User | |
form_class = UserRegistrationForm | |
template_name = 'accounts/form.html' | |
success_url = '/' | |
extra_context = { | |
'title': 'Register' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For python3 you would need to use | |
>>> exec(open('myscript.py').read()) | |
or | |
import os, django | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") | |
django.setup() | |
# now your code can go here... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
djangoapp/ | |
__init__.py | |
models.py | |
... | |
templatetags/ | |
__init__.py | |
custom_tags.py | |
Note:: After adding a new template tags module, you will need to restart | |
the Django development server in order to use the new template tags and filters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {withRouter} from 'react-router' | |
class Nav extends Component { | |
render () { | |
const { match, location, history } = this.props | |
return <h2>The Nav</h2> | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getDate(long time) { | |
Calendar cal = Calendar.getInstance(Locale.ENGLISH); | |
cal.setTimeInMillis(time); | |
return DateFormat.format("EEE, dd/MM/yyyy", cal).toString(); // EEE is for day of the week | |
} |
NewerOlder