my views.py is
down here which is an extension of
http://bitbucket.org/ubernostrum/django-registration/src/tip/registration/views.py
I am a total newbie here and don't know much about this..kindly
help...
from django.shortcuts import redirect
from django.shortcuts import render_to_response
from django.template import RequestContext
import profiles.utils
from registration.backends import get_backend
def activate(request, backend,
template_name='registration/activate.html',
success_url=None, extra_context=None, **kwargs):
backend = get_backend(backend)
account = backend.activate(request, **kwargs)
if account:
if success_url is None:
to, args, kwargs =
backend.post_activation_redirect(request, account)
return redirect(to, *args, **kwargs)
else:
return redirect(success_url)
if extra_context is None:
extra_context = {}
context = RequestContext(request)
for key, value in extra_context.items():
context[key] = callable(value) and value() or value
return render_to_response(template_name,
kwargs,
context_instance=context)
def ug_zero_suffix(form_data):
return form_data['username'] + '0'
username_generators = [ug_zero_suffix]
# Not a view function (helper function)
def generate_username_suggestions(form_data):
MAX_SUGGESTIONS = 5
suggestions = []
for gen in username_generators:
for suggestion in gen(form_data):
if (suggestion != None):
suggestions.append(suggestion)
if (length(suggestions) >= MAX_SUGGESTIONS):
return suggestions
# TODO make sure that we handle not generating enough
suggestions
return suggestions
def register(request, backend, success_url=None,
form_class=RegistrationForm, profile_callback=None,
template_name='registration/registration_form.html',
extra_context=None):
pform_class = profiles.utils.get_profile_form()
if request.method =='POST':
profileform = pform_class(data=request.POST,
files=request.FILES)
form = form_class(data=request.POST,
files=request.FILES)
if form.is_valid():
new_user = form.save()
profile_obj = profileform.save(commit=False)
profile_obj.user = new_user
profile_obj.save()
return HttpResponseRedirect('/accounts/
register/complete/')
else:
form = form_class()
profileform = pform_class()
if exra_context is None:
extra_context = {}
context = RequestContext(request)
for key, value in extra_context.items():
context[key] = callable(value) and value() or
value
return render_to_response(template_name,
{'form':form,'profileform':profileform,'context_instance':context})
def register(request, backend, success_url=None, form_class=None,
disallowed_url='registration_disallowed',
template_name='registration/registration_form.html',
extra_context=None):
backend = get_backend(backend)
if not backend.registration_allowed(request):
return redirect(disallowed_url)
if form_class is None:
form_class = backend.get_form_class(request)
if request.method == 'POST':
form = form_class(data=request.POST, files=request.FILES)
if form.is_valid():
new_user = backend.register(request, **form.cleaned_data)
if success_url is None:
to, args, kwargs =
backend.post_registration_redirect(request, new_user)
return redirect(to, *args, **kwargs)
else:
return redirect(success_url)
#else:
# generate suggestions which can be passed into the
template
else:
form = form_class()
if extra_context is None:
extra_context = {}
context = RequestContext(request)
for key, value in extra_context.items():
context[key] = callable(value) and value() or value
return render_to_response(template_name,
{ 'form': form },
context_instance=context)
On May 7, 11:25 am, Bayuadji <[email protected]> wrote:
> Hi,
>
> I don't know which version of django-registration you use,
> but the source on views.py doesn't have any profiles.utils
>
> see :http://bitbucket.org/ubernostrum/django-registration/src/tip/registra...
>
> -adji-
>
>
>
> On Fri, May 7, 2010 at 9:19 AM, newbiedjango <[email protected]> wrote:
> > hi all,
> > i am a newbie in django and have been trying to get this django-
> > registration app working with few extra fields.
>
> > now i am getting his module error
>
> >http://dpaste.com/191756/
>
> > please help fixing me this error..
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> --------------------------------------------------------------http://www.tumbletooth.org
> my linkedin profile :http://www.linkedin.com/in/bayuadji
> --------------------------------------------------------------
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group
> athttp://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.