2

I followed the installation instructions on django-user-accounts.

When calling http://[mysite]/account/signup

I could see:{# This template intentionally left blank to satisfy test suites. Your project should always provide a site_base.html itself. #} (and I take it as a good sign, I'll add my base template later).

After that, i created an app: ./manage.py startapp myapp_account ...and filled it with the minimum code from the "Usage" page of the manual mentioned above as i want to get a basic working register/login/out.

Now i get an error when calling http://[mysite]/account/signup/:

Exception Value:     'module' object has no attribute 'views'
Exception Location:  /var/www/venv/django_1/django_1/urls.py in <module>, line 10
Python Executable:   /var/www/venv/bin/python3.4

my code: urls.py (main project called django_1):

from django.conf.urls import patterns, include, url
import myapp_account

urlpatterns = patterns('',
    # this is line 10 in my case:
    url(r'^account/signup/$', myapp_account.views.SignupView(),name="account_signup"),
    url(r'^account/', include('account.urls')),
)         

myapp_account/views.py:

import account.views
import account.forms
import myapp_account.forms

class SignupView(account.views.SignupView):

    form_class = myapp_account.forms.SignupForm

    def after_signup(self, form):
        self.create_profile(form)
        super(SignupView, self).after_signup(form)

    def create_profile(self, form):
        profile = self.created_user.get_profile()
        profile.birthdate = form.cleaned_data["birthdate"]
        profile.save()

class LoginView(account.views.LoginView):
    form_class = account.forms.LoginEmailForm

myapp_account/forms.py

from django import forms
from django.forms.extras.widgets import SelectDateWidget
import account.forms

class SignupForm(account.forms.SignupForm):
    birthdate = forms.DateField(widget=SelectDateWidget(years=range(1930, 2010)))

Is there a simpler way do get it working and be on the right track to extend the user accounts step by step?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ralfr
  • 146
  • 1
  • 7

1 Answers1

0

As usual the answer was in the manual Django, Class-based views :

  1. Import the class based view directly
  2. Call the class based view directly in the url

updated urls.py (main)

from django.conf.urls import patterns, include, url
from myapp_account.views import SignupView # <- import class based view 

urlpatterns = patterns('',
    # call class based view directly:
    url(r'^account/signup/$', SignupView.as_view(), name="account_signup"),
    url(r'^account/', include('account.urls')),
)

Still i'd be happy if someone cloud point me to a well made example of django-user-accounts.

ralfr
  • 146
  • 1
  • 7
  • 1
    puzzled by django-user-accounts and the pinax-project-account... What's the difference between them? In my Django app, how should I use them... – dofine Jul 04 '16 at 16:54