Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-23 Thread Gourav Chawla
No sir please! Gourav is just fine.

Also, you would need to go edit/add code in the admin.py file for this to
work.

Try this part of the docs:

https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter

Hope, it helps.

On Mon, 22 Apr, 2019, 1:15 PM Balaji Shetty,  wrote:

> Dear Gaurav Sir
>
> I am very much thankful to you for your reply to my query.
>
> My questions is *How can i make  the customization in Django Admin Panel
> itself to implement necessary logic after user of particular department do
> the login.( How and where to embed proposed Logic
> T1.objects.filter(user=current_user, department=current_user.department)*
>
> If i design separate pages for login using templates and showing necessary
> content user-wise (Login wise),
> Your suggested logic will definitely work  (after making necessary changes
> in schema)
>
>
>
> On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
> gauravchawla.chawla...@gmail.com> wrote:
>
>> First of all, use appropriate model fields for linking objects. For
>> example users should be a foreign key to your(or Django's) user table.
>>
>> Then whenever you want to show data on any interface to any user, just
>> filter content/rows by user department.
>>
>> Something like:
>>
>> T1.objects.filter(user=current_user, department=current_user.department)
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHkVAtuWq0CF2J4X%3DnckroOZZpEk%2B%2BzgT1r76%2Bd-7SeWTYU4QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-22 Thread Balaji Shetty
Dear Gaurav Sir

I am very much thankful to you for your reply to my query.

My questions is *How can i make  the customization in Django Admin Panel
itself to implement necessary logic after user of particular department do
the login.( How and where to embed proposed Logic
T1.objects.filter(user=current_user, department=current_user.department)*

If i design separate pages for login using templates and showing necessary
content user-wise (Login wise),
Your suggested logic will definitely work  (after making necessary changes
in schema)



On Sun, Apr 21, 2019 at 11:00 AM Gourav Chawla <
gauravchawla.chawla...@gmail.com> wrote:

> First of all, use appropriate model fields for linking objects. For
> example users should be a foreign key to your(or Django's) user table.
>
> Then whenever you want to show data on any interface to any user, just
> filter content/rows by user department.
>
> Something like:
>
> T1.objects.filter(user=current_user, department=current_user.department)
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAECSbOvHwOk5Zn6qMQgbtG99wEo4yRV3UJwBHoc1_sQhwW1ZFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Sithembewena L. Dube
Your model fields are not cased correctly.

https://stackoverflow.com/questions/8908760/should-i-use-camel-case-or-underscores-in-python


Kind regards,
Sithu


*Sent with Shift
*

On Fri, Apr 19, 2019 at 6:23 PM Balaji Shetty 
wrote:

> HI
>
> My models.py
>
>
> class T1(models.Model):
> CaseNumber = models.TextField(blank=True,null=True)
> UserCurrent = models.TextField(blank=True,null=True,default='user1')
> UserCurrentDepartment = models.TextField(blank=True,null=True)
>
> def __str__(self):
> return '%s %s' % (self.CaseNumber , self.UserCurrentDepartment )
>
> 
>  Assume Record in MODELS T1  to be entered by respectuve user are
> (
> *  I will create System User U1, U2 and U3 for IT,CS and MECH Department
> only. *
> *)*
> CaseNumber  -- UserCurrent  --UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
>
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
>
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
>
> *when I run the Project by creating One Superuser*
>
> *http://127.0.0.1:8000/admin/appname/t1/
> *
>
> * i get all records of all Users and all Departments.*
> *I will create three user of Name U1,U2 and U3 of IT,CS and MECH
> Department and ask them to do CRUD Operation. I want the output in
> following way use rwise.*
>
>
> *When User U1 do the login in Admin Panel, He should get only his
> Department Records -IT, not other department*
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  11 - U1 - *iT*
>
> * 12 - U1 - IT*
>
> *13 - U1 - IT*
> *--*
>
> *When User U2 do the login in Admin Panel, He should get only his
> Department Records - CS,, not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  21 - U2 - *CS*
> * 22 - U2 - CS*
>
> *23 - U2- CS*
> *--*
>
> *When User U3 do the login in Admin Panel, He should get only his
> Department Records - MECH, , not other department*
>
>
> CaseNumber--   UserCurrent  --  UserCurrentDepartment
>  31 - U3 - *MECH*
>
> * 32 - U3 - MECH *
> *33 - U3 - MECH*
> *--*
>
> *When I create superuser, he has access to all user data.*
>
> *But other users U1, U2 and U3 have also access of other users Data.*
>
>
> *So My query is how can i accomplish this Constraint.*
>
> --.
>
> How can i write a customized query so that Admin panel should display only
> particular Department as per respective user Deparement.-
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOtiHTPCprTj9w168rHksoUf2TKsju-yQHZvJLw14eZ9Ag%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAH-SnCCSuqweF_hfSCUXR6p3O3WsHrNEWLcShe%2BdQx6tkYEkmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-20 Thread Gourav Chawla
First of all, use appropriate model fields for linking objects. For example 
users should be a foreign key to your(or Django's) user table.

Then whenever you want to show data on any interface to any user, just filter 
content/rows by user department.

Something like:

T1.objects.filter(user=current_user, department=current_user.department)

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4484706-2f3a-488c-a28c-41f78e2f42ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django How to write Customized Query ( Display Information Departmentwise)

2019-04-19 Thread Balaji Shetty
HI

My models.py


class T1(models.Model):
CaseNumber = models.TextField(blank=True,null=True)
UserCurrent = models.TextField(blank=True,null=True,default='user1')
UserCurrentDepartment = models.TextField(blank=True,null=True)

def __str__(self):
return '%s %s' % (self.CaseNumber , self.UserCurrentDepartment )


 Assume Record in MODELS T1  to be entered by respectuve user are
(
*  I will create System User U1, U2 and U3 for IT,CS and MECH Department
only. *
*)*
CaseNumber  -- UserCurrent  --UserCurrentDepartment
 11 - U1 - *iT*

* 12 - U1 - IT*

*13 - U1 - IT*

 21 - U2 - *CS*
* 22 - U2 - CS*

*23 - U2- CS*

 31 - U3 - *MECH*

* 32 - U3 - MECH *
*33 - U3 - MECH*
*--*


*when I run the Project by creating One Superuser*

*http://127.0.0.1:8000/admin/appname/t1/
*

* i get all records of all Users and all Departments.*
*I will create three user of Name U1,U2 and U3 of IT,CS and MECH Department
and ask them to do CRUD Operation. I want the output in following way use
rwise.*


*When User U1 do the login in Admin Panel, He should get only his
Department Records -IT, not other department*

CaseNumber--   UserCurrent  --  UserCurrentDepartment
 11 - U1 - *iT*

* 12 - U1 - IT*

*13 - U1 - IT*
*--*

*When User U2 do the login in Admin Panel, He should get only his
Department Records - CS,, not other department*


CaseNumber--   UserCurrent  --  UserCurrentDepartment
 21 - U2 - *CS*
* 22 - U2 - CS*

*23 - U2- CS*
*--*

*When User U3 do the login in Admin Panel, He should get only his
Department Records - MECH, , not other department*


CaseNumber--   UserCurrent  --  UserCurrentDepartment
 31 - U3 - *MECH*

* 32 - U3 - MECH *
*33 - U3 - MECH*
*--*

*When I create superuser, he has access to all user data.*

*But other users U1, U2 and U3 have also access of other users Data.*


*So My query is how can i accomplish this Constraint.*

--.

How can i write a customized query so that Admin panel should display only
particular Department as per respective user Deparement.-


*Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
*SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
*Official: bsshe...@sggs.ac.in  *
*  Mobile: +91-9270696267*

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAECSbOtiHTPCprTj9w168rHksoUf2TKsju-yQHZvJLw14eZ9Ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.