Hi
class Profile(models.Model):
RCS1 = "Regular_Civil_Suit"
SCS1 = "Special_Civil_Suit"
RCA1 = "Regular Civil Appeal"
MCA1 = "Miscellaneous Civil Appeal"
CMA1 = "Civil Miscellaneous Application"
LAR1 = "Land Acquisation Reference"
SED1 = "Special Execution Darkhast"
# AC1 = "Arbitration Case"
SuitType_Choice = [
(RCS1, 'Regular Civil Suit'),
(SCS1, 'Special Civil Suit'),
(RCA1, 'Regular Civil Appeal'),
(MCA1,'Miscellaneous Civil Appeal'),
(CMA1,'Civil Miscellaneous Application'),
(LAR1,'Land Acquisation Reference'),
(SED1,'Special Execution Darkhast'),
# (AC1,'Arbitration Case'),
]
State = models.CharField(max_length=100,default="MH")
District = models.CharField(max_length=100,default="Parbhani")
user = models.ForeignKey(User, on_delete=models.CASCADE,default="--")
InwardNumber = models.CharField(max_length=100,default="2019/3")
CaseNoticeDate = models.DateField(default="2019-01-24")
CaseNoticeSubject = models.CharField(max_length=100,default="Inquiry in Department")
CaseReceiverName = models.CharField(max_length=100,default="Ramakant Lal")
CaseInwardDate = models.DateField(default="2019-02-24")
CaseActionTaken=models.CharField(max_length=200,default="Verification is going on")
CourtType =models.CharField(max_length=200,default="District Court Parbhani")
SuitType= models.CharField(max_length=200,choices=SuitType_Choice,
default="Regular Civil Suit",verbose_name='--Suit Type-')
# decision_taken = models.CharField(max_length=50, choices=court_action,
# default="Appeared",verbose_name='Court Decision-')
CaseYear = models.PositiveIntegerField(default=2019)
CaseNumber = models.PositiveIntegerField(default=1)
CaseSubmittedDate = models.DateField(default="2019-01-14")
# Current_Date= models.DateField(default=timezone.now)
CaseSubject=models.CharField(max_length=200,default="Corruption and Dowry")
CaseAdvocate=models.CharField(max_length=200,default="Reguar Civil Suit")
CasePartyNames=models.CharField(max_length=200,default="Manish Singh")
CaseOppositePartyNames=models.CharField(max_length=200,default="Raj Kumar ")
CaseLastDate = models.DateField(default="2019-05-24")
UserCurrent = models.CharField(max_length=200,default="user1")
UserCurrentDate = models.DateField(default="2019-03-24")
UserCurrentDepartment = models.CharField(max_length=200,default="IT")
UserNext = models.CharField(max_length=200,default="user2")
UserNextDate = models.DateField(default="2019-06-24")
UserNextDepartment = models.CharField(max_length=200,default="CS")
CaseStatus= models.CharField(max_length=100,default="Pending")
# CaseNumber = models.PositiveIntegerField(default=1)
# CaseYear = models.PositiveIntegerField(default=2019)
class Meta:
unique_together = (('CaseNumber', 'CaseYear'),)
def __str__(self):
return '%s/%s' % (self.CaseNumber, self.CaseYear)
Sorry
This is my model
class Profile(models.Model):
RCS1 = "Regular_Civil_Suit"
SCS1 = "Special_Civil_Suit"
RCA1 = "Regular Civil Appeal"
MCA1 = "Miscellaneous Civil Appeal"
CMA1 = "Civil Miscellaneous Application"
LAR1 = "Land Acquisation Reference"
SED1 = "Special Execution Darkhast"
# AC1 = "Arbitration Case"
SuitType_Choice = [
(RCS1, 'Regular Civil Suit'),
(SCS1, 'Special Civil Suit'),
(RCA1, 'Regular Civil Appeal'),
(MCA1,'Miscellaneous Civil Appeal'),
(CMA1,'Civil Miscellaneous Application'),
(LAR1,'Land Acquisation Reference'),
(SED1,'Special Execution Darkhast'),
# (AC1,'Arbitration Case'),
]
State = models.CharField(max_length=100,default="MH")
District = models.CharField(max_length=100,default="Parbhani")
user = models.ForeignKey(User, on_delete=models.CASCADE,default="--")
InwardNumber = models.CharField(max_length=100,default="2019/3")
CaseNoticeDate = models.DateField(default="2019-01-24")
CaseNoticeSubject = models.CharField(max_length=100,default="Inquiry in Department")
CaseReceiverName = models.CharField(max_length=100,default="Ramakant Lal")
CaseInwardDate = models.DateField(default="2019-02-24")
CaseActionTaken=models.CharField(max_length=200,default="Verification is going on")
CourtType =models.CharField(max_length=200,default="District Court Parbhani")
SuitType= models.CharField(max_length=200,choices=SuitType_Choice,
default="Regular Civil Suit",verbose_name='--Suit Type-')
# decision_taken = models.CharField(max_length=50, choices=court_action,
# default="Appeared",verbose_name='Court Decision-')
CaseYear = models.PositiveIntegerField(default=2019)
CaseNumber = models.PositiveIntegerField(default=1)
CaseSubmittedDate = models.DateField(default="2019-01-14")
# Current_Date= models.DateField(default=timezone.now)
CaseSubject=models.CharField(max_length=200,default="Corruption and Dowry")
CaseAdvocate=models.CharField(max_length=200,default="Reguar Civil Suit")
CasePartyNames=models.CharField(max_length=200,default="Manish Singh")
CaseOppositePartyNames=models.CharField(max_length=200,default="Raj Kumar ")
CaseLastDate = models.DateField(default="2019-05-24")
UserCurrent = models.CharField(max_length=200,default="user1")
UserCurrentDate = models.DateField(default="2019-03-24")
UserCurrentDepartment = models.CharField(max_length=200,default="IT")
UserNext = models.CharField(max_length=200,default="user2")
UserNextDate = models.DateField(default="2019-06-24")
UserNextDepartment = models.CharField(max_length=200,default="CS")
CaseStatus= models.CharField(max_length=100,default="Pending")
# CaseNumber = models.PositiveIntegerField(default=1)
# CaseYear = models.PositiveIntegerField(default=2019)
class Meta:
unique_together = (('CaseNumber', 'CaseYear'),)
def __str__(self):
return '%s/%s' % (self.CaseNumber, self.CaseYear)
On Mon, May 27, 2019 at 10:12 PM Derek <gamesbook@gmail.com> wrote:
Your first error refers to a ProfileForm; you need to post the form definition code here as well.--
On Sunday, 26 May 2019 20:48:09 UTC+2, Balaji wrote:HiHere i want to exclude some model filed depending upon type of User.Example if username is "dgp", i want to excludein admin.pyif username == "dgp":
self.exclude = ("UserNext","UserNextDate","UserNextDepartment","CaseStatus")indef get_form(self, request, obj=None, **kwargs):
I do not use fieldset and comment the code, i get field excluded in "dgp" Login. Code execute successfully and fields get excluded.But if i use filedset, I get the errorKeyError at /admin/newapp/profile/add/
"Key 'UserNext' not found in 'ProfileForm'. Choices are: CaseActionTaken,
CaseAdvocate, CaseInwardDate, CaseLastDate, CaseNoticeDate, CaseNoticeSubject,4
CaseNumber, CaseOppositePartyNames, CasePartyNames, CaseReceiverName,
CaseSubject, CaseSubmittedDate, CaseYear, CourtType, District,
InwardNumber, State, SuitType, user."------------------------------------------here is admin.pyclass ProfileAdmin(admin.ModelAdmin):
save_on_top = True
save_as = True
list_display = ('user','CaseNumber','CaseYear','InwardNumber','CaseNoticeDate','CaseNoticeSubject',
'CaseReceiverName','CaseInwardDate','CaseActionTaken','CaseAdvocate','CasePartyNames',
'CaseOppositePartyNames','CaseLastDate','user','UserNext','UserNextDate','UserNextDepartment','CaseStatus'
)search_fields = ['user','CaseNumber','CaseYear','InwardNumber','CaseNoticeDate','CaseNoticeSubject',
'CaseReceiverName','CaseInwardDate','CaseActionTaken','CaseAdvocate','CasePartyNames',
'CaseOppositePartyNames','CaseLastDate','user','UserNext','UserNextDate','UserNextDepartment','CaseStatus'
]
fieldsets = [
('Location information',
{'fields': ['State','District','user'] } ),
('Department Internal information', {'classes':['collapse'],'fields': [ ('InwardNumber','CaseInwardDate'),
('CaseNoticeSubject','CaseNoticeDate',),('CaseReceiverName','CaseActionTaken') ] } ),
('Court Case Information', {'classes':['collapse'],
'fields': [ ('CourtType','SuitType'),
('CaseYear','CaseNumber'),('CaseSubject','CaseSubmittedDate') ] } ),
('Party Information', {'classes':['collapse'],
'fields': [ ('CaseAdvocate'),
('CasePartyNames','CaseOppositePartyNames'),'CaseLastDate' ] } ),
('Incharge Officer Information', {'classes':['collapse'],
'fields': [ ('UserNext','UserNextDate'),
('UserNextDepartment','CaseStatus') ] } )
]
list_per_page = 5
def get_form(self, request, obj=None, **kwargs):username = request.user.username
print (username)
if username == "dgp":
self.exclude = ("UserNext","UserNextDate","UserNextDepartment","CaseStatus")
# self.exclude = ("location","birth_date","bio", )
form = super(ProfileAdmin, self).get_form(request, obj, **kwargs)
return form
else:
form = super(ProfileAdmin, self).get_form(request, obj, **kwargs)
return formCan anybody help me in this regards.If i comment Fieldset, than code works in "dgp" login with hiding necessary fields.Also my search is not workingFieldError at /admin/newapp/profile/
Related Field got invalid lookup: icontains--Mr. Shetty Balaji S.
Asst. Professor
Department of Information Technology,SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.IndiaOfficial: bssh...@sggs.ac.inMobile: +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+unsubscribe@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/555a679b-3b7f-4275-823e-383b380865f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mr. Shetty Balaji S.
Asst. Professor
Department of Information Technology,
Asst. Professor
Department of Information Technology,
SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India
Official: bsshetty@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+unsubscribe@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/CAECSbOt3-qo21ZqvfMsuOQX5BnWK5BMFeQp4JAxo5Pq4hMBbmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment