How to approach

2021-11-04 Thread Trippy Samurai
Hi there,
I am new to django and have a problem statement am not quite sure how to 
approach this,Please help me,


Phase 1 Objectives:

   1. Use the existing project setup you have already created  You may 
   completely reset Django models/database/codebase if needed but make sure 
   you keep celery/redist/celery flower docker setup 
   2. Extend default Django user model (very imp. you should research/read 
   on this if not sure)
   a. user with same email address can only signup as either manager or as 
   developer
   b. Add more models as needed (i.e. Ticket etc)
   3. Create different Profile models for PM and Developer (hint: one to 
   one relation to User)  
   4. Create Two signup page where user can create account as project 
   manager and as  developer 
   5. Create two different login pages for PMs and Developers 
   6. Each user type is greeted with basic welcome message i.e. dashboard


PM Features :

   1. Can create new ticket with title and info/description field 
   2. Can mark ticket as closed once it is marked completed by developer


Developer Features:

   1. Can accept one or more Ticket if it is open
   2. After accepting a ticket it can not be accepted by another developer. 
   Only one user can accept one ticket at a time
   3. Developer can then mark accepted ticket as completed 


Phase 2 Objectives: 

   1.  PM Dashboard :
  1. See existing Open tickets
  2. See Accepted tickets 
  3. See Completed tickets
  4. See Closed tickets 
   2. Developer Dashboard 
  1. See Open tickets 
  2. See Accepted tickets 
  3. See Completed tickets 
  4. See Closed tickets
   

   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/eb344d25-1f60-4cae-8f2f-0e6abb2417abn%40googlegroups.com.


Re: How to approach

2021-11-05 Thread Trippy Samurai
As i am beginner i am struggling I tried and created as per it,I created 
two signup forms and login pages with same logic i.e same code snippet two 
times while signup it's fine but while logging in irrespective of the 
usertype it is logging into same user every time ,The issue here is how do 
i differentiate the user while logging in,Please take a look at the code 
and give inputs.


*models.py*

class Developer(models.Model):
developer = models.OneToOneField(User,on_delete=models.CASCADE)
is_developer = models.BooleanField(default=True)


def __str__(self):
return self.user.username 

class ProjectManager(models.Model):
manager = models.OneToOneField(User,on_delete=models.CASCADE)
is_developer = models.BooleanField(default=False)

def __str__(self):
return self.user.username





*forms.py:*

class DeveloperForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())

class Meta():
model = User
fields = ('username','email','password')


class ProjectManagerForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta():
model = User
fields = ('username','email','password')


*views.py:*


def index(request):
return render(request,'app/index.html',{})


def register(request):
return render(request,'app/register.html')

def user_login(request):
return render(request,'app/login.html')

def developer_signup(request):
registered = False

if request.method == 'POST':
user_form = DeveloperForm(data=request.POST)

if user_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
registered = True
else:
print(user_form.errors)
else:
user_form = DeveloperForm()
return render(request,'app/dev-signup.html',
{'user_form':user_form,
'registered':registered})

def manager_signup(request):
registered = False

if request.method == 'POST':
pm_form = ProjectManagerForm(data=request.POST)

if pm_form.is_valid():
user = pm_form.save()
user.set_password(user.password)
user.save()
registered = True
else:
print(pm_form.errors)
else:
pm_form = ProjectManagerForm()
return render(request,'app/pm-signup.html',
{'pm_form':pm_form,
'registered':registered})


def pm_signin(request):

if request.method=='POST':
username=request.POST.get('username')
password=request.POST.get('password')

manager=authenticate(username=username,password=password)

if manager:
if manager.is_active:
login(request,manager)
return render(request,'app/dev-dash.html')
else:
return HttpResponse('account not active')
else:
print ('someone failed login')
print ('email: {} and password: {}'.format(username,password))

return HttpResponse('invalid login')
else:
return render(request,'app/pm-signin.html',{})


def dev_signin(request):

if request.method=='POST':
username=request.POST.get('username')
password=request.POST.get('password')

developer=authenticate(username=username,password=password)

if developer:
if developer.is_active:
login(request,developer)
return render(request,'app/pm-dash.html')
else:
return HttpResponse('account not active')
else:
print ('someone failed login')
print ('email: {} and password: {}'.format(username,password))

return HttpResponse('invalid login')
else:
return render(request,'app/pm-signin.html',{})




On Friday, 5 November 2021 at 07:54:14 UTC+5:30 riis@gmail.com wrote:

> i agree with kasper, but one tip is to start with the user class.
> check out django.contrib.auth.base_user
>
> Den tors 4 nov. 2021 kl 18:36 skrev Kasper Laudrup :
>
>> On 04/11/2021 14.54, Trippy Samurai wrote:
>> > Hi there,
>> > I am new to django and have a problem statement am not quite sure how 
>> to 
>> > approach this,Please help me,
>> >
>>
>> I think you should approach it just as it has been described, i.e. one 
>> step at a time.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> -- 
>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9c9dbfc3-8fa8-5ff2-8405-f5614da92f55%40stacktrace.dk
>> .
>>
>

-- 
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/e6481a7c-d6ef-417e-a2e9-e7c22e27127cn%40googlegroups.com.


Celery & Docker Setup

2021-11-10 Thread Trippy Samurai
Hello,
I have around 18 views in my views.py file how do i integrate with 
celery,Please help me if anyone's aware

*Views*.*py:*

from django import forms
from django.contrib import auth
from django.http import request
from django.http.response import HttpResponse, HttpResponseRedirect
from django.shortcuts import render,redirect
from django.urls import reverse
from django.contrib.auth import login,logout,authenticate
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.views.generic import CreateView
from .forms import 
DeveloperSignupForm,ProjectManagerSignupForm,TicketCreateForm
from django.contrib.auth.forms import AuthenticationForm
from .models import Developer, User,Ticket

# Create your views here.
def index(request):
return render(request,'app/login_register_page.html')

class developer_register(CreateView):
model = User
form_class = DeveloperSignupForm
template_name = 'app/dev_register.html'

def form_valid(self,form):
user = form.save()
return HttpResponse('Thank you for Registering,Please Login')


class manager_register(CreateView):
model = User
form_class = ProjectManagerSignupForm
template_name = 'app/pm_register.html'

def form_valid(self,form):
user = form.save()
return HttpResponse('Thank you for Registering,Please Login')



def manager_login(request):
current = User.objects.filter(is_manager = True)
if request.method == 'POST':
pm_form = AuthenticationForm(data=request.POST)

if pm_form.is_valid():
username = pm_form.cleaned_data.get('username')
password = pm_form.cleaned_data.get('password')
user = authenticate(username=username,password=password)

if user is not None:
if user in current:
login(request,user)
return redirect(reverse('pm_dashboard'))
else:
messages.error(request,"Invalid Username or Password")

else:
messages.error(request,"Invalid Username or Password")
return render(request, 'app/pm_login.html',context={
'form':AuthenticationForm(),
})

@login_required
def pm_dashboard(request):
return render(request,'app/pm_dash.html')




def developer_login(request):
current = User.objects.filter(is_developer = True)
if request.method == 'POST':
dev_form = AuthenticationForm(data=request.POST)

if dev_form.is_valid():
username = dev_form.cleaned_data.get('username')
password = dev_form.cleaned_data.get('password')
user = authenticate(username=username,password=password)

if user is not None:
if user in current:
login(request,user)
return redirect(reverse('dev_dashboard'))

else:
messages.error(request,"Invalid Username or Password")

else:
messages.error(request,"Invalid Username or Password")
return render(request, 'app/dev_login.html',context={
'form':AuthenticationForm(),
})
@login_required
def dev_dashboard(request):
return render(request,'app/dev_dash.html')

@login_required
def ticket_create_view(request):

if request.POST:
form = TicketCreateForm(request.POST)

if form.is_valid():

obj = form.save()
obj.created_by = request.user
obj.status = "Opened"
obj.save()

return HttpResponseRedirect(reverse('pm_open_tickets'))

else:
form = TicketCreateForm()

return render(request,
'app/create_ticket.html',
{'form': form,})

@login_required
def open_tickets_view(request):
tickets_open = Ticket.objects.filter(status = 'Opened') 
return render(request,'app/open_tickets.html',{"tickets": tickets_open})
@login_required
def accept_tickets_view(request,pk):
ticket = Ticket.objects.get(id=pk)
if ticket.status == 'Opened':
ticket.status = 'Accepted'
ticket.accepted_by = request.user
ticket.save()
return redirect(reverse('open_tickets'))

@login_required
def dev_accepted_ticket(request):
ticket_complete = Ticket.objects.filter(status = 'Accepted',accepted_by = 
request.user)
return render(request,'app/dev_accepted_ticket.html',{"tickets": 
ticket_complete})


@login_required
def mark_complete_tickets_view(request,pk):
ticket = Ticket.objects.get(id=pk)
if ticket.status == 'Accepted' and ticket.accepted_by == request.user:
ticket.status = 'Completed'
ticket.save()
return redirect(reverse('accepted_tickets_view'))


@login_required
def dev_completed_ticket(request):
tickets_completed = Ticket.objects.filter(status = 'Completed',accepted_by 
= request.user)
return 
render(request,'app/dev_complete_ticket.html',{'tickets':tickets_completed})

@login_required
def dev_closed_tickets_view(request):
tickets_closed = Ticket.objects.filter(status='Closed',accepted_by = 
request.user)
return 
render(request,'app/dev_closed_tickets.html',{'tickets':tickets_closed})


@login_required
def pm_open_tickets_view(request):
tickets_open = Ticket.objects.filter(status = 'Opened',created_by = 
request.user) 
return render(request,'app/pm_open_tickets.html',{"tickets": tickets_open})


@login_required
def pm_accepted_tickets(request):
ticket_complete = Ticket.objects.filter(status = 'Accepted',created_by = 
request.user)
return render(request,'app/pm_accepted_tickets.html',{"tickets": 
ticket_complete})


@login_required
def pm_completed_tickets(request):
ticket

Re: Celery & Docker Setup

2021-11-10 Thread Trippy Samurai
Thanks edchels for the link considering the views is it possible to add?


On Wednesday, 10 November 2021 at 15:52:14 UTC+5:30 edchels...@gmail.com 
wrote:

> Checkout this tutorial 
>
> https://realpython.com/asynchronous-tasks-with-django-and-celery/
>
> On Wed, 10 Nov 2021 at 17:12, Trippy Samurai  
> wrote:
>
>> Hello,
>> I have around 18 views in my views.py file how do i integrate with 
>> celery,Please help me if anyone's aware
>>
>> *Views*.*py:*
>>
>> from django import forms
>> from django.contrib import auth
>> from django.http import request
>> from django.http.response import HttpResponse, HttpResponseRedirect
>> from django.shortcuts import render,redirect
>> from django.urls import reverse
>> from django.contrib.auth import login,logout,authenticate
>> from django.contrib.auth.decorators import login_required
>> from django.contrib import messages
>> from django.views.generic import CreateView
>> from .forms import 
>> DeveloperSignupForm,ProjectManagerSignupForm,TicketCreateForm
>> from django.contrib.auth.forms import AuthenticationForm
>> from .models import Developer, User,Ticket
>>
>> # Create your views here.
>> def index(request):
>> return render(request,'app/login_register_page.html')
>>
>> class developer_register(CreateView):
>> model = User
>> form_class = DeveloperSignupForm
>> template_name = 'app/dev_register.html'
>>
>> def form_valid(self,form):
>> user = form.save()
>> return HttpResponse('Thank you for Registering,Please Login')
>>
>>
>> class manager_register(CreateView):
>> model = User
>> form_class = ProjectManagerSignupForm
>> template_name = 'app/pm_register.html'
>>
>> def form_valid(self,form):
>> user = form.save()
>> return HttpResponse('Thank you for Registering,Please Login')
>>
>>
>>
>> def manager_login(request):
>> current = User.objects.filter(is_manager = True)
>> if request.method == 'POST':
>> pm_form = AuthenticationForm(data=request.POST)
>>
>> if pm_form.is_valid():
>> username = pm_form.cleaned_data.get('username')
>> password = pm_form.cleaned_data.get('password')
>> user = authenticate(username=username,password=password)
>>
>> if user is not None:
>> if user in current:
>> login(request,user)
>> return redirect(reverse('pm_dashboard'))
>> else:
>> messages.error(request,"Invalid Username or Password")
>>
>> else:
>> messages.error(request,"Invalid Username or Password")
>> return render(request, 'app/pm_login.html',context={
>> 'form':AuthenticationForm(),
>> })
>>
>> @login_required
>> def pm_dashboard(request):
>> return render(request,'app/pm_dash.html')
>>
>>
>>
>>
>> def developer_login(request):
>> current = User.objects.filter(is_developer = True)
>> if request.method == 'POST':
>> dev_form = AuthenticationForm(data=request.POST)
>>
>> if dev_form.is_valid():
>> username = dev_form.cleaned_data.get('username')
>> password = dev_form.cleaned_data.get('password')
>> user = authenticate(username=username,password=password)
>>
>> if user is not None:
>> if user in current:
>> login(request,user)
>> return redirect(reverse('dev_dashboard'))
>>
>> else:
>> messages.error(request,"Invalid Username or Password")
>>
>> else:
>> messages.error(request,"Invalid Username or Password")
>> return render(request, 'app/dev_login.html',context={
>> 'form':AuthenticationForm(),
>> })
>> @login_required
>> def dev_dashboard(request):
>> return render(request,'app/dev_dash.html')
>>
>> @login_required
>> def ticket_create_view(request):
>>
>> if request.POST:
>> form = TicketCreateForm(request.POST)
>>
>> if form.is_valid():
>>
>> obj = form.save()
>> obj.created_by = request.user
>> obj.status = "Opened"
>> obj.save()
>>
>> return HttpResponseRedirect(reverse('pm_open_tickets'))
>>
>> else:
>> form = TicketCreateForm()
>>
>> return render(request,
>> 'app/create_ticket.html',
>> {'form': form,})
>>
>> @login_required
>> def open_tickets_view(request):
>> tickets_open = Ticket.objects.filter(status = 

Re: How to approach

2021-11-15 Thread Trippy Samurai
The conclusion is that i have 8 html pages  4 for developer and 4 for 
manager which have slight changes in the table headers i.e 
Opened,accepted.completed,closed, aftter using listview all of them come 
into one html file because of one model i need them to display accordingly 
with respect to each user logged in . How do i acheive this

On Monday, 15 November 2021 at 21:17:50 UTC+5:30 Trippy Samurai wrote:

> Hi elgato,
> Thanks for your reply brother
>
> I need to change the function based views into class based and generic 
> views, previously i have implemented different html pages for all the views 
> like completed,opened,accepted and closed tickets, with class based views i 
> need to have everything in one single html file ri8 if i am not wrong it 
> follows some convention like modelname_list.html on top of that i have 
> multi user signin developer and manager.i am stuck with this how to 
> implement and u can see the html file below which displays the open tickets 
> for developer and there are 8 different html pages for developer and 
> manager for 4 status of ticket as i mentioned at the starting of this 
> message they all should be in one html page if i use class based generic 
> view(list view) i am stuck plz help
>
>
> [image: Screenshot 2021-11-15 at 9.09.41 PM.png]
>
>
> [image: Screenshot 2021-11-15 at 8.57.33 PM.png]
> On Monday, 15 November 2021 at 19:19:42 UTC+5:30 elgato...@gmail.com 
> wrote:
>
>> Hi Trippy.
>>
>> Be more specific about what part is causing you troubles
>>
>> El jue, 4 de nov. de 2021 a la(s) 10:59, Trippy Samurai (
>> someshkan...@gmail.com) escribió:
>>
>>> Hi there,
>>> I am new to django and have a problem statement am not quite sure how to 
>>> approach this,Please help me,
>>>
>>>
>>> Phase 1 Objectives:
>>>
>>>1. Use the existing project setup you have already created  You may 
>>>completely reset Django models/database/codebase if needed but make sure 
>>>you keep celery/redist/celery flower docker setup 
>>>2. Extend default Django user model (very imp. you should 
>>>research/read on this if not sure)
>>>a. user with same email address can only signup as either manager or 
>>>as developer
>>>b. Add more models as needed (i.e. Ticket etc)
>>>3. Create different Profile models for PM and Developer (hint: one 
>>>to one relation to User)  
>>>4. Create Two signup page where user can create account as project 
>>>manager and as  developer 
>>>5. Create two different login pages for PMs and Developers 
>>>6. Each user type is greeted with basic welcome message i.e. 
>>>dashboard
>>>
>>>
>>> PM Features :
>>>
>>>1. Can create new ticket with title and info/description field 
>>>2. Can mark ticket as closed once it is marked completed by developer
>>>
>>>
>>> Developer Features:
>>>
>>>1. Can accept one or more Ticket if it is open
>>>2. After accepting a ticket it can not be accepted by another 
>>>developer. Only one user can accept one ticket at a time
>>>3. Developer can then mark accepted ticket as completed 
>>>
>>>
>>> Phase 2 Objectives: 
>>>
>>>1.  PM Dashboard :
>>>   1. See existing Open tickets
>>>   2. See Accepted tickets 
>>>   3. See Completed tickets
>>>   4. See Closed tickets 
>>>2. Developer Dashboard 
>>>   1. See Open tickets 
>>>   2. See Accepted tickets 
>>>   3. See Completed tickets 
>>>   4. See Closed tickets
>>>
>>>
>>>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...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/eb344d25-1f60-4cae-8f2f-0e6abb2417abn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/eb344d25-1f60-4cae-8f2f-0e6abb2417abn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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/da911740-17ea-4e4c-bd73-94b7bc3e8b50n%40googlegroups.com.


change function based view into class based view

2021-11-16 Thread Trippy Samurai
Hello guys,

I have to change the function based views to class based views please check 
the github question i have posted please answer if any knows plz


https://stackoverflow.com/questions/69986690/change-the-function-based-views-to-class-based-generic-viewsupdate-view

-- 
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/759a694b-f266-4217-a912-545c470eb13fn%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-21 Thread Trippy Samurai
Any one plz


On Sunday, 21 November 2021 at 15:09:39 UTC+5:30 Trippy Samurai wrote:

> Hello,
> I have different views for displaying different templates how do i write 
> them into one single Listview so that i can take care of DRY
>
>
> [image: Screenshot 2021-11-21 at 3.08.58 PM.png]
>

-- 
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/d86e1449-a17e-4e93-9dd2-1fae9a7e91d7n%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-21 Thread Trippy Samurai
Hi Elena Thanks for the reply i have three different html pages to display 
open tickets closed tickets accepted tickets etc each of them have 
different ticket statuses i have them written in different views as above 
to display each type of ticket at different pages how can i combine all 
three in  a single view so that i dont repeat my logic in views.Is there a 
way to acheive all the three views writing in a single view?

On Monday, 22 November 2021 at 10:04:14 UTC+5:30 elena wrote:

> Hi,
>
> The problem is it's unclear what your question is. Can you be clearer 
> about what outcome you're trying to achieve? 
>
>
> ---
> Elena Williams
> Github: elena <http://github.com/elena/>
>
>
> On Mon, 22 Nov 2021 at 15:20, Trippy Samurai  
> wrote:
>
>> Any one plz
>>
>>
>> On Sunday, 21 November 2021 at 15:09:39 UTC+5:30 Trippy Samurai wrote:
>>
>>> Hello,
>>> I have different views for displaying different templates how do i write 
>>> them into one single Listview so that i can take care of DRY
>>>
>>>
>>> [image: Screenshot 2021-11-21 at 3.08.58 PM.png]
>>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d86e1449-a17e-4e93-9dd2-1fae9a7e91d7n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/d86e1449-a17e-4e93-9dd2-1fae9a7e91d7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/c5eeae75-7c09-4f7e-928c-d03d5f10165an%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-21 Thread Trippy Samurai
What about the templates i have three different templates for as u can see 
in template_name in the above views ,how do i deal with it if i actualyl 
had one template the above could have worked.
On Monday, 22 November 2021 at 12:42:59 UTC+5:30 sutharl...@gmail.com wrote:

> we can go like 
>
> ```
>
> class Manager(...):
> def get_context_data(self, **kwargs):
> context = super() 
> context["open_tickets"] = Ticket.objects.filter(status="OPEN")
> context["accepted_tickets"] = Ticket.objects.filter(status="ACCEPTED")
> context["completed_tickets"] = Ticket.objects.filter(status="COMPLETED")
> return context
> ```
>
> On Mon, 22 Nov 2021 at 12:19, Trippy Samurai  
> wrote:
>
>> Hi Elena Thanks for the reply i have three different html pages to 
>> display open tickets closed tickets accepted tickets etc each of them have 
>> different ticket statuses i have them written in different views as above 
>> to display each type of ticket at different pages how can i combine all 
>> three in  a single view so that i dont repeat my logic in views.Is there a 
>> way to acheive all the three views writing in a single view?
>>
>> On Monday, 22 November 2021 at 10:04:14 UTC+5:30 elena wrote:
>>
>>> Hi,
>>>
>>> The problem is it's unclear what your question is. Can you be clearer 
>>> about what outcome you're trying to achieve? 
>>>
>>>
>>> ---
>>> Elena Williams
>>> Github: elena <http://github.com/elena/>
>>>
>>>
>>> On Mon, 22 Nov 2021 at 15:20, Trippy Samurai  
>>> wrote:
>>>
>>>> Any one plz
>>>>
>>>>
>>>> On Sunday, 21 November 2021 at 15:09:39 UTC+5:30 Trippy Samurai wrote:
>>>>
>>>>> Hello,
>>>>> I have different views for displaying different templates how do i 
>>>>> write them into one single Listview so that i can take care of DRY
>>>>>
>>>>>
>>>>> [image: Screenshot 2021-11-21 at 3.08.58 PM.png]
>>>>>
>>>> -- 
>>>> 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...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/d86e1449-a17e-4e93-9dd2-1fae9a7e91d7n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/django-users/d86e1449-a17e-4e93-9dd2-1fae9a7e91d7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/c5eeae75-7c09-4f7e-928c-d03d5f10165an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/c5eeae75-7c09-4f7e-928c-d03d5f10165an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/a000369b-b20f-4737-9bdc-f913f5af0a08n%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-22 Thread Trippy Samurai
Thanks David for the idea i appreciate it i have gone with last way of 
doing things but it doesnt render anything on data

Pls correct my code below 



*views.py:*

class DeveloperTicketView(TemplateView):
template_name = 'app/ticket_view.html'
ticket = Ticket.objects.all()
extra_content = {'ticket_type':ticket}

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['open_tickets'] = Ticket.objects.filter(status = 'Opened')
context['accepted_tickets'] = Ticket.objects.filter(status = 
'Accepted',accepted_by = self.request.user)
context['completed_tickets'] = Ticket.objects.filter(status = 
'Completed',accepted_by = self.request.user)
context['closed_tickets'] = Ticket.objects.filter(status = 
'Closed',accepted_by = self.request.user)
return context



ticket_view.html

{% extends 'app/base.html' %}

{% block body %} 
{% for tickets in ticket_type%}
{% if tickets.status == "Opened" %}



ID
Status
Created
Title
Description



{% for ticket in open_tickets %}

{{ ticket.id }}
{{ ticket.status }}
{{ ticket.created_by }}
{{ ticket.ticket_title }}
{{ ticket.ticket_description }}
 Accept

{% endfor %}

{% elif tickets.status == 'Accepted' %}



ID
Status
Created by
Title
Description

 


{% for ticket in accepted_tickets %}

{{ ticket.id }}
{{ ticket.status }}
{{ ticket.created_by }}
{{ ticket.ticket_title }}
{{ ticket.ticket_description }}
Complete

{% endfor %}


{% elif tickets.status == 'Completed' %}





ID
Status
Created by
Title
Description

 


{% for ticket in completed_tickets %}

{{ ticket.id }}
{{ ticket.status }}
{{ ticket.created_by }}
{{ ticket.ticket_title }}
{{ ticket.ticket_description }}

{% endfor %}
{% else %}



ID
Status
Created by
Title
Description




{% for ticket in closed_tickets %}

{{ ticket.id }}
{{ ticket.status }}
{{ ticket.created_by }}
{{ ticket.ticket_title }}
{{ ticket.ticket_description }}

{% endfor %}
{% endif %}
{% endfor %}
{% endblock %}




On Monday, 22 November 2021 at 13:22:47 UTC+5:30 David Nugent wrote:

> Well, there are several ways you can deal with that.
>
> Probably easiest is to override get_template() and switch the template 
> based on whatever type of ticket you're managing or you can change the 
> value of self.template_name based on the request.
>
> Or maybe you prefer a single template to deal with all cases with 
> conditional blocks where appropriate.
>
>
> Regards,
> David
>

-- 
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/786fa7af-0a81-4cf7-9a2e-c2fd2e9f0323n%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-22 Thread Trippy Samurai
Anyone plz review my code i am struggling to figure out what the issue here 
is

On Monday, 22 November 2021 at 16:35:32 UTC+5:30 Trippy Samurai wrote:

> Thanks David for the idea i appreciate it i have gone with last way of 
> doing things but it doesnt render anything on data
>
> Pls correct my code below 
>
>
>
> *views.py:*
>
> class DeveloperTicketView(TemplateView):
> template_name = 'app/ticket_view.html'
> ticket = Ticket.objects.all()
> extra_content = {'ticket_type':ticket}
>
> def get_context_data(self, **kwargs):
> context = super().get_context_data(**kwargs)
> context['open_tickets'] = Ticket.objects.filter(status = 'Opened')
> context['accepted_tickets'] = Ticket.objects.filter(status = 
> 'Accepted',accepted_by = self.request.user)
> context['completed_tickets'] = Ticket.objects.filter(status = 
> 'Completed',accepted_by = self.request.user)
> context['closed_tickets'] = Ticket.objects.filter(status = 
> 'Closed',accepted_by = self.request.user)
> return context
>
>
>
> ticket_view.html
>
> {% extends 'app/base.html' %}
>
> {% block body %} 
> {% for tickets in ticket_type%}
> {% if tickets.status == "Opened" %}
> 
> 
> 
> ID
> Status
> Created
> Title
> Description
> 
> 
> 
> {% for ticket in open_tickets %}
> 
> {{ ticket.id }}
> {{ ticket.status }}
> {{ ticket.created_by }}
> {{ ticket.ticket_title }}
> {{ ticket.ticket_description }}
>  Accept
> 
> {% endfor %}
> 
> {% elif tickets.status == 'Accepted' %}
> 
> 
> 
> ID
> Status
> Created by
> Title
> Description
> 
>  
>
> 
> {% for ticket in accepted_tickets %}
> 
> {{ ticket.id }}
> {{ ticket.status }}
> {{ ticket.created_by }}
> {{ ticket.ticket_title }}
> {{ ticket.ticket_description }}
> Complete
> 
> {% endfor %}
> 
>
> {% elif tickets.status == 'Completed' %}
>
> 
>
> 
> 
> ID
> Status
> Created by
> Title
> Description
> 
>  
>
> 
> {% for ticket in completed_tickets %}
> 
> {{ ticket.id }}
> {{ ticket.status }}
> {{ ticket.created_by }}
> {{ ticket.ticket_title }}
> {{ ticket.ticket_description }}
> 
> {% endfor %}
> {% else %}
> 
> 
> 
> ID
> Status
> Created by
> Title
> Description
> 
> 
>
> 
> {% for ticket in closed_tickets %}
> 
> {{ ticket.id }}
> {{ ticket.status }}
> {{ ticket.created_by }}
> {{ ticket.ticket_title }}
> {{ ticket.ticket_description }}
> 
> {% endfor %}
> {% endif %}
> {% endfor %}
> {% endblock %}
>
>
>
>
> On Monday, 22 November 2021 at 13:22:47 UTC+5:30 David Nugent wrote:
>
>> Well, there are several ways you can deal with that.
>>
>> Probably easiest is to override get_template() and switch the template 
>> based on whatever type of ticket you're managing or you can change the 
>> value of self.template_name based on the request.
>>
>> Or maybe you prefer a single template to deal with all cases with 
>> conditional blocks where appropriate.
>>
>>
>> Regards,
>> David
>>
>

-- 
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/c31184b3-6ab9-4b71-a233-6b81cb5e4331n%40googlegroups.com.


Re: Multiple Templates in single list view

2021-11-22 Thread Trippy Samurai
Its done bro model is configured already i didn't just posted the models.py 
file

On Monday, 22 November 2021 at 21:18:12 UTC+5:30 ram.asf...@gmail.com wrote:

> will update asap
>
> On Mon, Nov 22, 2021 at 1:22 PM David Nugent  wrote:
>
>> Well, there are several ways you can deal with that.
>>
>> Probably easiest is to override get_template() and switch the template 
>> based on whatever type of ticket you're managing or you can change the 
>> value of self.template_name based on the request.
>>
>> Or maybe you prefer a single template to deal with all cases with 
>> conditional blocks where appropriate.
>>
>>
>> Regards,
>> David
>>
>> -- 
>>
> 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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAE5VhgUCCnmkm%2BBe0EWLK4Nb%3DXUOHZAEYGax%2B2%2B-kCysYxdzHA%40mail.gmail.com
>>  
>> 
>> .
>>
>

-- 
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/8a2eadcf-5733-439b-b763-4eb70db91429n%40googlegroups.com.


'WSGIRequest' object has no attribute 'get'

2021-11-22 Thread Trippy Samurai
Getting error while working with template view

views.py 


class DeveloperTicketView(TemplateView):

def get_template_names(self):
if self.request.get('status') == 'Opened':
template_name = 'app/open_tickets.html'
elif self.request.get('status') == 'Accepted':
template_name = 'app/dev_accepted_tickets'
elif self.request.get('status') == "Completed":
template_name = 'app/dev_completed_tickets.html'
else:
template_name = 'app/dev_closed_tickets.html'

return template_name


def get_context_data(self, **kwargs):
context = super(DeveloperTicketView,self).get_context_data(**kwargs)
context['open_tickets'] = Ticket.objects.filter(status = 'Opened')
context['accepted_tickets'] = Ticket.objects.filter(status = 
'Accepted',accepted_by = self.request.user)
context['completed_tickets'] = Ticket.objects.filter(status = 
'Completed',accepted_by = self.request.user)
context['closed_tickets'] = Ticket.objects.filter(status = 
'Closed',accepted_by = self.request.user)
return context

-- 
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/65cd3d84-5946-43d6-8abc-c78e4246fb07n%40googlegroups.com.


django restrict choice options in dropdown according to the user type

2021-12-10 Thread Trippy Samurai
Hi,

I have two user types usertype a and usertype b i have a form to update the 
task with fields name,info and status i have STATUS_CHOICES = (

('A','A'),
('B','B'),
('C','C')
)

the user type a should c only ('A','A'),('B','B'), in dropdown and usertype 
b should have (C,C) as dropdown how do i acheive this in django


forms.py


class Form(forms.ModelForm):
class Meta:
model = Model
fields = (name', 'info',status')

-- 
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/54e89c90-4c22-4fc7-9582-667becdcd541n%40googlegroups.com.


django download view downloading only .xls instead of file with extension on model

2022-02-26 Thread Trippy Samurai
https://stackoverflow.com/questions/71277673/django-download-view-downloading-only-xls-instead-of-file-with-extension-on-mod

-- 
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/12549cf3-d81b-427d-87e2-a79097593c7cn%40googlegroups.com.


Show particular records at the bottom page

2022-03-27 Thread Trippy Samurai
Hello all,
I have a view that show the records,These records have certain statuses i 
want to show a particular status to be at the bottom of the list in website 
how can acheive this my view is drf APIView.

-- 
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/e3bcf84c-d256-46b9-a88c-a83b9fd6e11cn%40googlegroups.com.


django queryset - Get the data particular to current year only

2022-03-30 Thread Trippy Samurai



I have my query written to get some thing from database and display on my 
website that query is getting all the data from db but what if i want to 
get the data particular to current year only


def get(self, request, *args, **kwargs):
filters = self.get_filters()

result = Model.objects.all().filter(*filters).distinct().aggregate(
t=Sum('t'),
b=Sum('b'),
)

result2 = Model.objects.all().filter(*filters).distinct().aggregate(
past_due=Sum('balance', filter=Q(due_date__lt=timezone.now()))
)

zero = Decimal('0.00')

total = result['t'] or zero
balance = result['b'] or zero
past_due = result2['past_due'] or zero
amount_received = t - b

-- 
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/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com.


Re: django queryset - Get the data particular to current year only

2022-04-04 Thread Trippy Samurai
Thanks for the reply Brother but it's already solved

On Sunday, 3 April 2022 at 12:05:39 UTC+5:30 sutharl...@gmail.com wrote:

> I think this is related to your query
> https://stackoverflow.com/a/28101722/8882295
>
> On Thu, 31 Mar 2022 at 11:22, Trippy Samurai  
> wrote:
>
>>
>> <https://stackoverflow.com/posts/71687249/timeline>
>>
>> I have my query written to get some thing from database and display on my 
>> website that query is getting all the data from db but what if i want to 
>> get the data particular to current year only
>>
>>
>> def get(self, request, *args, **kwargs):
>> filters = self.get_filters()
>>
>> result = Model.objects.all().filter(*filters).distinct().aggregate(
>> t=Sum('t'),
>> b=Sum('b'),
>> )
>>
>> result2 = Model.objects.all().filter(*filters).distinct().aggregate(
>> past_due=Sum('balance', filter=Q(due_date__lt=timezone.now()))
>> )
>>
>> zero = Decimal('0.00')
>>
>> total = result['t'] or zero
>> balance = result['b'] or zero
>> past_due = result2['past_due'] or zero
>> amount_received = t - b
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/14733a49-9175-4fa5-a09e-0de0c6881ccdn%40googlegroups.com.


Generalize search criterion django and drf

2022-04-04 Thread Trippy Samurai
I have ListView where i display some results on my website and i have 
search parameter which gives the result based on title and number here i 
should ignore the exact spelling and show the results for both i.e search 
criterion to be able to ignore "." "et al." and similar terms so that when 
searching titles the name doesn't have to be exact. I.E. "Toaster v fridge" 
will still bring up "Toaster, et al. v. Fridge"


class MyListAPIView(ListAPIView):
 def get_filters(self, request): 
 filters = []
 id_list = request.query_params.getlist('id[]', [])
 if id_list:
filters.append(Q(id__in=id_list))

return filters

search = request.query_params.get('search', '')
if search:
filters.append(Q(c_number__icontains=search) | 
Q(title__icontains=search))
return filters

-- 
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/ae754e29-a767-4b40-949c-3b0d7aa45ec0n%40googlegroups.com.


file upload to folder based on selected category on form

2022-04-08 Thread Trippy Samurai
Hello,
In my website i am uploading the documents and has title, category(choice 
field) and file upload on my website, here the file upload stores normally 
on the admin but how can i store the file inside the seperate folder based 
on the selected category for ex if the file i am uploading belongs to the 
category(choice field) named 'X' it should be stored in the folder 'X' 
likewise for all the other documents should be stored in their respective 
folders named after category Types.


-- 
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/ba00044f-909e-4d19-80e6-b21f2c462c4en%40googlegroups.com.


Multiple Update Tasks

2022-05-25 Thread Trippy Samurai
I have my Django website where i can have tasks created and subtasks under 
tasks i have mark complete option which is working fine i need them to be 
completed in batch like selecting multiple tasks at once and complete them.

**serializers.py**:

class TaskCompleteSerializer(serializers.ModelSerializer):
 class Meta:
model = Task
fields = (
'is_done',
)

 def update(self, instance, validated_data):
 person = self.context['request'].user.person

 task_is_done = validated_data.get('is_done', False)

 if task_is_done:
instance.subtasks.update(is_done=True)

 instance.is_done = task_is_done
 instance.done_by.set([person])
 instance.save()

 return instance

**views.py**:

class TaskUpdateAPIView(UpdateAPIView):
 permission_classes = " "
 serializer_class = TaskCompleteSerializer
 queryset = Task.objects.all()
 model = Task
 lookup_url_kwarg = 'task_id'

**urls.py**

path('/complete/',views.TaskUpdateAPIView.as_view(), 
name='task_update'),

**models.py**

class Task(BaseModel):
name = models.CharField(max_length=255)
done_by = models.ManyToManyField(
User,
related_name='tasks_completed',
blank=True,
)
is_done = models.BooleanField(default=False)

-- 
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/331763ee-17f4-4713-8d26-884696413328n%40googlegroups.com.