django-1.10

DRF auth_token: “non_field_errors”: [ “Unable to log in with provided credentials.”

僤鯓⒐⒋嵵緔 提交于 2020-03-20 06:04:06
问题 Both JWT packages written for Django gave me issues with poor documentation, so I try DRF-auth_token package. This is a good example I followed, Django Rest Framework Token Authentication. You should in theory be able to go to localhost:8000/api-token-auth/ urls.py: from django.conf.urls import url, include from django.contrib import admin from django.contrib.auth.models import User from rest_framework.authtoken import views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^api/',

django 1.10 media images don't show

我与影子孤独终老i 提交于 2020-01-13 04:52:49
问题 I have had django media images working in an existing django 1.7 project by adding the following to site urls.py: urlpatterns = patters( url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), ) This url structure doesn't work in django 1.10 and so I changed it to the reccommended here Django MEDIA_URL and MEDIA_ROOT: urlpatterns = [ ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) This fails to render any

Django user has_perm returning false even though group has permission

一曲冷凌霜 提交于 2020-01-05 05:30:11
问题 I'm running into a problem where I've created a Group with certain permissions, and successfully added a user to that group, but when I check user.has_perm with that permission, I'm getting False. I've even tried things like saving the user and re-fetching them from the database to avoid caching issues, but it makes no difference. The terminal output below should give an idea of what's happening # Get a group from the database and check its permissions > special_group = Group.objects.get(name

Problems with editing multiupload image field

只愿长相守 提交于 2019-12-25 16:55:57
问题 I have problem with editing form in django. Pls can someone help me? I have form with 2 fields: description and image . By this form users can edit currect article data. For example add new several images to article or update/delete one of the currect image. To create image field I used django-multiupload app. Also I load data to server by ajax. I tried next code but it didnt show me currect images in image field. Only descrtiption field works fine and show me currect data. How to fix this

Embedding Videos in my Django site

三世轮回 提交于 2019-12-22 18:24:06
问题 I have no idea about embedding videos in Django. I am storing my videos in a database. I need to do embedding, displaying and deleting my videos in my Django site. Can any one give a right direction for do this. Thanks in advance. 回答1: Hi this question is a little tricky. Django is basically a framework for creating web apps using python, you are saying you already have a Django website and you are not explaining what you have, also not specifying what format you have for your videos (e.g.:

How create Multiple Select Box in Django?

让人想犯罪 __ 提交于 2019-12-21 17:47:36
问题 I am tring to create Multiple Select Box field from Django Select 2 library as in the picture below? I used next code but it return simple select multiple widget. I think I forgot something to add. Where is my mistake? Can someone show me how create such field correctly? I use: django-select-2 version: 5.1.0 JQuery version: 3.1.1 forms.py: class ProductForm(forms.ModelForm): company = forms.ModelMultipleChoiceField(queryset=Company.objects.none()) class Meta: model = Product fields = (

Django: apps.get_models() yields models from unittests

℡╲_俬逩灬. 提交于 2019-12-13 08:10:03
问题 If I call this django method, in a test, it yields a lot of models which are not installed. These models are from other apps test code. For example, when iI use apps.get_models() I get MROBase1 from the django package polymorphic test code. => I want get all models which have a table in the database. In above question I got a model which exists just for testing, which is not on the database. NB: I use Django 1.10 回答1: You need to isolate the models from your application(s): Create manually, a

Django 1.10 Templating/staticfiles not showing any images

寵の児 提交于 2019-12-12 01:56:30
问题 I am trying to enable Django templating in 1.10 and it is not behaving correctly. Anything I have referenced to be called from the static files (./manage.py collectstatic) is not showing where referenced in the html. I have it imported in my views: from django.shortcuts import render, render_to_response from django.http import HttpResponse, HttpResponseRedirect from django.contrib.auth.forms import UserCreationForm from django.template import loader from django.contrib.auth.decorators import

How to disable checkboxes in MultipleChoiceField?

99封情书 提交于 2019-12-11 04:45:05
问题 I use MultipleChoiceField in form. It shows me REQUIREMENTS_CHOICES list with checkboxes where user can select and add new requirements to database. Is it possible to disable checkboxes (in my case requirements) which is already in the database? Lets say I have A and C in database so I dont need them. First value in tulpe is symbol of requirement, second value is the name of requirement. models.py: class Requirement(models.Model): code = models.UUIDField(_('Code'), primary_key=True, default

How create Multiple Select Box in Django?

早过忘川 提交于 2019-12-04 14:19:14
I am tring to create Multiple Select Box field from Django Select 2 library as in the picture below? I used next code but it return simple select multiple widget. I think I forgot something to add. Where is my mistake? Can someone show me how create such field correctly? I use: django-select-2 version: 5.1.0 JQuery version: 3.1.1 forms.py: class ProductForm(forms.ModelForm): company = forms.ModelMultipleChoiceField(queryset=Company.objects.none()) class Meta: model = Product fields = ('company ',) widgets = { 'company': Select2MultipleWidget() } def __init__(self, all_companies, *args, *