django-1.11

Custom “authentication_form” does not apply bootstrap CSS

﹥>﹥吖頭↗ 提交于 2020-01-07 03:58:12
问题 I'm attempting to apply bootstrap to a django login form. I have scoured google for hours and pretty much everyone is saying the same thing, which is to set the custom authentication_form in urls.py , override the username and password fields in custom login form and pass the class through the widget's attrs parameter. I have done this but django still isn't applying the form-control class to my input fields. I'm not quite sure what is going wrong. The form still renders, but without applying

Admin inline with no ForeignKey relation

二次信任 提交于 2019-12-23 08:20:34
问题 Is it possible to manually specify the set of related object to show in an inline, where no foreign key relation exists? # Parent class Diary(models.Model): day = models.DateField() activities = models.TextField() # Child class Sleep(models.Model): start_time = models.DateTimeField() end_time = models.DateTimeField() class SleepInline(admin.TabularInline): model=Sleep def get_queryset(self, request): # Return all Sleep objects where start_time and end_time are within Diary.day return Sleep

Admin inline with no ForeignKey relation

无人久伴 提交于 2019-12-23 08:20:18
问题 Is it possible to manually specify the set of related object to show in an inline, where no foreign key relation exists? # Parent class Diary(models.Model): day = models.DateField() activities = models.TextField() # Child class Sleep(models.Model): start_time = models.DateTimeField() end_time = models.DateTimeField() class SleepInline(admin.TabularInline): model=Sleep def get_queryset(self, request): # Return all Sleep objects where start_time and end_time are within Diary.day return Sleep

No confirmation of authenticate(username=username, password=password) in django-python3-ldap

梦想的初衷 提交于 2019-12-14 04:03:31
问题 I'm trying to develop what should be a relative simple web application that requests a user to log in via LDAP, then if successfully logged in, the user can then search for another user(s) in the LDAP server. It's an application for admin people. The code so far creates/binds to the ldap server, and upon finding the searched user, a different page is displayed showing the user's credentials. Connectivity via the correct credentials has been confirmed via the ldap3 library. On the second

prevent SQL injection in django forms

£可爱£侵袭症+ 提交于 2019-12-13 10:29:52
问题 I use this for validation: class MyValidationForm(forms.Form): title = forms.CharField() body = forms.Textarea() taxonomy = forms.IntegerField() and this is my class-based view: class blog_createpost(dashboardBaseViews): template_name = "dashboardtems/blog_createpost.html" model = {} def post(self, request, *args, **kwargs): form = MyValidationForm(request.POST) if not form.is_valid(): return HttpResponse("not valid") new_data = post(title=request.POST['title'], body=request.POST['body'],

Django 1.11 on passenger_wsgi not routing POST request

梦想与她 提交于 2019-12-13 00:33:44
问题 I'm trying to setup python on A2 shared hosting via passenger_wsgi. The app is working fine when I run it via 'runserver'. I tested this both in my local PC, and via SSH tunnel. However, when I try to set this up on passenger_wsgi, it can't seem to be able to route POST request. 1 import os 2 import sys 3 4 sys.path.insert(0, "/home/<username>/app") 5 6 import APP_CORE 7 8 # where is the python interpreter 9 INTERP = "/home/<username>/app/.virtualenv/bin/python" 10 if sys.executable != INTERP

Django FilteredSelectMultiple not rendering on page

自作多情 提交于 2019-12-12 18:14:09
问题 I am currently using Django version 1.11.2 and would like to use the FilteredSelectMultiple widget outside of the admin page. This is my forms.py: class TBDAuthGroupManageForm(forms.Form): permissions = forms.ModelMultipleChoiceField(queryset=Permission.objects.all(), required=True, widget=FilteredSelectMultiple("Permissions", is_stacked=False)) class Media: css = {'all': ('/static/admin/css/widgets.css',), } js = ('/admin/jsi18n/',) def __init__(self, parents=None, *args, **kwargs): super

redirect user after update in class based view in django

我是研究僧i 提交于 2019-12-12 13:27:15
问题 I'm using Django 1.11. I'm using Class based view for update profile page, to updated auth user profile info. myapp/accounts/views.py class UpdateProfile(UpdateView): model = User fields = ['first_name', 'last_name'] template_name = 'accounts/update.html' def __init__(self, **kwargs): super().__init__(**kwargs) self.request = None def get_object(self, queryset=None): return self.request.user This works fine for updating profile. But after update, it gives error No URL to redirect to. Either

Django template keyword `choice_value` in no longer work in 1.11

拥有回忆 提交于 2019-12-10 01:35:00
问题 There is a multiple checkbox in template, if value contain in render the choice will checked by default. It works well with 1.10. form.py: class NewForm(forms.Form): project = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Project.objects.filter(enable=True) ) template: {% for p in form.project %} <label for="{{ p.id_for_label }}"> <input type="checkbox" name="{{ p.name }}" id="{{ p.id_for_label }}" value="{{ p.choice_value }}" {% if p.choice_value|add:"0" in

Django template keyword `choice_value` in no longer work in 1.11

空扰寡人 提交于 2019-12-05 01:03:41
There is a multiple checkbox in template, if value contain in render the choice will checked by default. It works well with 1.10. form.py: class NewForm(forms.Form): project = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Project.objects.filter(enable=True) ) template: {% for p in form.project %} <label for="{{ p.id_for_label }}"> <input type="checkbox" name="{{ p.name }}" id="{{ p.id_for_label }}" value="{{ p.choice_value }}" {% if p.choice_value|add:"0" in form.project.initial %} checked{% endif %}> <p>{{ p.choice_label }}</p> </label> {% endfor %} views.py: