Re: im a newbe, i'm trying to get the username in a view

2020-11-14 Thread David Nugent
The pre-requisite for having ‘user’ in the request instance is the ‘django.contrib.auth.context_processors.auth’ in your TEMPLATES context_processors. See the second answer (should be the accepted one as it has received far more community votes) in this stack overflow article

Re: How to print sequence number in python

2020-11-14 Thread mike vickers
Python has the enumerate function for these situations. for i, item in enumerate(items): #your print statement here 'i' will give you the index of the list/iterable, and item will give you the item. On Sat, 14 Nov 2020 at 11:57, paidjoo indo wrote: > Hello I'm newbie in python, I'm learni

How to print sequence number in python

2020-11-14 Thread paidjoo indo
Hello I'm newbie in python, I'm learning looping in python, how to print like in bellow; Input:5 12345 2. 4 3 3 4 2 54321 Thanks guys -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop recei

Re: im a newbe, i'm trying to get the username in a view

2020-11-14 Thread mike vickers
You would want to include that line in a method, not as a class attribute. For example: def get(self, request): user = request.user.username ... return render(... On Sat, Nov 14, 2020 at 9:37 AM Kasper Laudrup wrote: > Hi Barbara, > > On 13/11/2020 22.46, Barbara Leonar

Re: im a newbe, i'm trying to get the username in a view

2020-11-14 Thread Kasper Laudrup
Hi Barbara, On 13/11/2020 22.46, Barbara Leonard wrote: make an attribute named "user" How would that help? The attribute value should be set to the currently logged in user. Just adding the attribute to request object will not do that. Clearly something else is missing. Kind regards, Ka

Re: im a newbe, i'm trying to get the username in a view

2020-11-14 Thread Kasper Laudrup
Hi Apolo, On 13/11/2020 19.19, Apolo Machine wrote: I'm trying to get the username within a view(CBV), the documentation I found says that the logged user is within the request, but when I do class ServiceCreateView(LoginRequiredMixin, CreateView):   model = Service   form_cl

Re: Template inheritance with dynamic content

2020-11-14 Thread Tristania W
; <https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#include> > directive. > > > Just have your parent and child include the same block and use with… > phrase to override variables within the included template. > > Regards, > David > > > On