Created
September 30, 2014 01:30
-
-
Save natehefner/e0f4aa7f6ba66e6ef6ab to your computer and use it in GitHub Desktop.
Django Update View Without Slug
This file contains 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
from django.conf.urls import patterns, include, url | |
from .views import UserUpdate | |
urlpatterns = patterns( | |
'', | |
url(r'^settings/$', UserUpdate.as_view(), name='accounts_settings'), | |
) |
This file contains 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
from django.views.generic.edit import UpdateView | |
from django.core.urlresolvers import reverse_lazy | |
from braces.views import LoginRequiredMixin | |
from .models import NeighborhoodNetUser | |
from .forms import SettingsForm | |
class UserUpdate(LoginRequiredMixin, UpdateView): | |
model = NeighborhoodNetUser | |
form_class = SettingsForm | |
template_name = 'accounts/settings.html' | |
success_message = 'Your settings have been saved.' | |
success_url = reverse_lazy('home') | |
def get_object(self): | |
return NeighborhoodNetUser.objects.get(email=self.request.user.email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment