admin

Django admin validation for inline form which rely on the total of a field between all forms

天涯浪子 提交于 2021-02-06 10:00:52
问题 Forgive me if this has been answered before, I couldn't find an answer where the validation depended on the aggregate of inline forms. Little background: I'm doing a site for an insurance broker which has 'Policies' and a 'Total Commission' of that policy. There are also 'Resellers' which are added to the 'Policy' along with a commission which goes to them (can have any number of resellers). The total commission between the resellers has to be less than the total commission. I have an admin

How to add readonly inline on django admin

ⅰ亾dé卋堺 提交于 2021-02-05 19:09:54
问题 I am using django 1.4 and I have a many2many field, so when creating the admin site I wanted to add this field as an inline, here is some code: class SummaryInline(admin.TabularInline): model = ParserError.summaries.through class MyClassAdmin(admin.ModelAdmin): list_display = ('classifier', 'name', 'err_count', 'supported') fields = ('classifier', 'name', 'err_count', 'err_classifier', 'supported') inlines = (SummaryInline,) readonly_fields = ('classifier', 'err_count') So my question is, how

How to add readonly inline on django admin

[亡魂溺海] 提交于 2021-02-05 19:06:42
问题 I am using django 1.4 and I have a many2many field, so when creating the admin site I wanted to add this field as an inline, here is some code: class SummaryInline(admin.TabularInline): model = ParserError.summaries.through class MyClassAdmin(admin.ModelAdmin): list_display = ('classifier', 'name', 'err_count', 'supported') fields = ('classifier', 'name', 'err_count', 'err_classifier', 'supported') inlines = (SummaryInline,) readonly_fields = ('classifier', 'err_count') So my question is, how

Django: access to user info from admin.py for methods with no request object?

萝らか妹 提交于 2021-01-29 21:32:06
问题 Django 1.11. In admin.py I have: class AuditAdmin(DeactivateMixin, admin.ModelAdmin): """all the superclass stuff""" from which I subclass my model's stuff with various custom methods: class SomeModelAdmin(AuditAdmin): list_display = ["filed1", "filed2", "field3"] def get_queryset(self, request): if request.user.is_superuser: #do something extra def inline_add_somemodelattribute1(self, my_object): #how to access user if I don't have request ? So inside inline_add_somemodelattribute1 method I

Django Invalid Syntax Error

与世无争的帅哥 提交于 2021-01-28 06:34:32
问题 I am at my wits. I am trying to set up Django admin but I am having a hard time. I have followed the Django book and checked several times but get an invalid syntax (urls.py, line 23). from django.conf.urls.defaults import * from mysite.views import hello, current_datetime, hours_ahead # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^hello/$', hello), (r'^time/$', current_datetime), (r'^time/plus/(\d{1,2})

Can network admin change the default port for http

流过昼夜 提交于 2021-01-25 07:15:51
问题 I gave an answer to following thread. but in the comment a user suggested that network admin can change the default port of http from 80 to something else. As for as I know if I open a page eg. http://www.example.com without port that means it is running on port 80. I just want to clarify that is it possible for network admin to change default port? 回答1: When using a browser, http://www.example.com will always try and connect to the server's TCP port 80, like it's port 443 for HTTPS

How to send input to cmd when cmd is running as administrator?

∥☆過路亽.° 提交于 2021-01-23 07:53:25
问题 I created an application that sends keyboard input to cmd.exe . This works when running cmd as a normal user but fails when cmd is run as Administrator. This is my code: Var Wnd:hwnd; begin wnd:=FindWindow('ConsoleWindowClass',0); if wnd <> 0 then begin setforegroundWindow(wnd); keybd_event(Ord('A'),0,0,0); end; end; Notice that ConsoleWindowClass is the class name of cmd . How can I send input to cmd when cmd is running as administrator? 回答1: How can I type with this code inside cmd when cmd

Firebase Firestore: custom admin access

蹲街弑〆低调 提交于 2021-01-21 03:48:09
问题 In Firebase Firestore, I'm trying to allow only (custom-assigned) admins to write/update/delete resources, and for that I've got these security rules: service cloud.firestore { match /databases/{database}/documents { match /resources { allow read; allow write, update, delete: if get(/users/$(request.auth.uid).isAdmin); } match /resources/{resource} { allow read; allow write, update, delete: if get(/users/$(request.auth.uid).isAdmin); } } } I'm signing in with the user that is marked as an

Django admin groups permissions and access

孤者浪人 提交于 2020-12-15 06:42:15
问题 I'm searching for a way to customize the Django Administration to support permissions and data based on the user group. For example, I've just created the Developers1, Developers2 groups.. now I've also created the Transaction model, with AdminModel to specify how to list data. Transacton model: class Transaction(models.Model): income_period_choices = (('Weekly', 'Weekly'), ('Fortnightly', 'Fortnightly')) chp_reference = models.CharField(max_length=50, unique=True) rent_effective_date =