further to my previous comments please share the your related model code to 
make discussion interesting...
On Sunday, September 20, 2020 at 11:35:05 AM UTC-4 Lightning Bit wrote:

> Hi all, 
>
> I am trying to figure out how to add "Customers" using code. Please look 
> at the administration layout: 
>
> [image: HELP.png]
>
> I was able to add to "Groups" using the following code in "views.py": 
>
> *@unauthenticated_user*
> *def registerPage(request):*
>
> *            form = CreateUserForm()*
>
> *            if request.method == 'POST':*
> *                form = CreateUserForm(request.POST)*
> *                if form.is_valid():*
> *                    user = form.save()*
> *                    username = form.cleaned_data.get('username')*
>                     
> *                    group = Group.objects.get(name='customer')*
> *                    user.groups.add(group)*
>                     
>
>
>
> *                    messages.success(request, 'BOLT Force account was 
> created for' + username )*
> *                    return redirect('login')*
>
> *            data= cartData(request)*
>
> *            items=data['items']*
> *            order=data['order']*
> *            cartItems=data['cartItems']*
>
> *            products = Product.objects.all()*
>
> *            context = {'products':products, 'items':items, 'order':order, 
> 'cartItems':cartItems, 'form':form}*
> *            return render(request, 'store/register.html', context)*
>
> However, I am unsure of how to add to the "Customers" section of the 
> picture above. I have tried almost every technique with no luck. I wanted 
> both the "Groups" and the "Customers" to have the same registered person 
> added at once. Would anyone happen to know how to fix this? 
>
> Thank you!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76689278-42d6-4fbf-83d1-248b2a9721b8n%40googlegroups.com.

Reply via email to