Compare commits
3 Commits
master
...
registrati
Author | SHA1 | Date |
---|---|---|
Fred | e9d2d4fea0 | |
Fred | 48aa115a17 | |
Fred | e41c4975cb |
|
@ -50,7 +50,7 @@ ROOT_URLCONF = 'gwift.urls'
|
|||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': ['templates'],
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
|
|
|
@ -22,5 +22,6 @@ import wish
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^accounts/', include('registration.backends.simple.urls')),
|
||||
url(r'^', include('wish.urls', namespace='wish')),
|
||||
]
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Registration{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ form }}
|
||||
<input type="submit"/>
|
||||
{% endblock %}
|
|
@ -0,0 +1,16 @@
|
|||
# coding: utf-8
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
"""
|
||||
Voir l'explication complète ici:
|
||||
http://stackoverflow.com/questions/3523745/best-way-to-do-register-a-user-in-django
|
||||
"""
|
||||
|
||||
class UserForm(django.forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
|
||||
class UserFormProfile(django.forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
|
@ -24,7 +24,7 @@ class Wishlist(AbstractModel):
|
|||
name = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
external_id = models.UUIDField(unique=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
owner = models.ForeignKey(User)
|
||||
|
||||
class Wish(AbstractModel):
|
||||
|
||||
|
|
|
@ -14,8 +14,13 @@ Class-based views
|
|||
Including another URLconf
|
||||
1. Add an import: from blog import urls as blog_urls
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
|
||||
|
||||
See http://www.obeythetestinggoat.com/using-the-built-in-views-and-forms-for-new-user-registration-in-django.html
|
||||
for user registration
|
||||
"""
|
||||
from django.conf.urls import url
|
||||
from django.conf.urls import url, include
|
||||
from django.views.generic.edit import CreateView
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
|
||||
from .views import WishListList, WishListDetail, WishDetail, UpdateWishView
|
||||
|
||||
|
@ -24,4 +29,10 @@ urlpatterns = [
|
|||
url(r'^list/(?P<pk>\d+)/$', WishListDetail.as_view(), name='wishlist'),
|
||||
url(r'^wish/(?P<pk>\d+)/$', WishDetail.as_view(), name='wish'),
|
||||
url(r'^wish/(?P<pk>\d+)/edit$', UpdateWishView.as_view(), name='wish-edit'),
|
||||
url(r'^register/', CreateView.as_view(
|
||||
template_name='register.html',
|
||||
form_class=UserCreationForm,
|
||||
success_url='/'
|
||||
)),
|
||||
url('^accounts/', include('django.contrib.auth.urls'))
|
||||
]
|
||||
|
|
|
@ -10,16 +10,19 @@ class WishListList(ListView):
|
|||
model = Wishlist
|
||||
template_name = 'wish/list.html'
|
||||
|
||||
|
||||
class WishListDetail(DetailView):
|
||||
context_object_name = 'wishlist'
|
||||
model = Wishlist
|
||||
template_name = 'wish/list_detail.html'
|
||||
|
||||
|
||||
|
||||
class WishDetail(DetailView):
|
||||
context_object_name = 'wish'
|
||||
model = Wish
|
||||
template_name = 'wish/wish_detail.html'
|
||||
|
||||
|
||||
|
||||
class UpdateWishView(UpdateView):
|
||||
model = Wish
|
||||
fields = ('name', 'description')
|
||||
|
|
Loading…
Reference in New Issue