Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to update multiple objects at once in Django?
As the image presents I have to update multiple objects at once, e.g. to update the status of each object. If the status is active, the object will display on another page and vice versa. The goal is to change the status of one object (or all) with one button. At the moment if I click on 'Update_all' I got only one value. Django's Admin Page to take action on multiple objects would be a nice solution, but I have no idea, how this template is constructed although I considered the html code of the template. Another try I attempted - similiar to the image above - was this one: My template <div class="container"> {% if forms.items %} {% for key,value in forms.items %} <form class="custom-form-manage-habis" method="post" action=""> {% csrf_token %} <div class="container custom-div-manage-habits"> {{key}} &emsp; {{value}} </div> <hr> {% endfor %} {% else %} <p>There are no habits to manage.</p> {% endif %} <input type="submit" value="Apply changes" {% if not forms.items %}style="display:none"{% endif %} ></input> </form> </div> ...and in my view: def post(self, request): print('postFuction') print(request.POST) form_collection = {} habit_update_list = request.POST.getlist('is_active') print(habit_update_list) habits = Habit.objects.filter(created_by=request.user.userprofile) i = 0 for habit in habits: print('I: ' + str(i)) form = … -
Regex validator does not work with Django admin forms
I try to use a RegexValidator with a CharField, but I can't make it work... class Configuration(models.Model): name = models.CharField(verbose_name=u'Name', validators = [RegexValidator(regex="[a-z]", message="Not cool", code="nomatch")]) I then just register it with admin.site.register(Configuration) But then in the admin forms, it accepts any possible name... Is the validation system suppose to work like that, or am I missing something ? -
NameError: name 'QuerySet' is not defined
I'm getting the NameError: name 'QuerySet' is not defined error in below line. QuerySet(query=MappingTraineeQ.objects.filter(date__range=(startdate,enddate)).query, model=MappingTraineeQ) I'm not getting the problem, do I need to import anything for this? or I missed something. please help me with the above. Thanks -
How to submit two ModelMultipleChoiceFields inputs as one ManyToMany field in Django Admin?
Here is my model: class Gym(TranslatableModel, BaseActive): ... tag_list = models.ManyToManyField(Tag) @property def services(self): return self.tag_list.filter(category=TagCategory.GYM_SERVICE) @property def activities(self): return self.tag_list.filter(category=TagCategory.GYM_ACTIVITY) And here is how the GymAdmin renders: First I needed to divide the "Tag List" multiple select input in the admin into two separate multiple select fields, namely "Services" and "Activities". So I did this: class GymForm(forms.ModelForm): class Meta: model = Gym fields = '__all__' exclude = ['tag_list',] services = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Tag.objects.filter(category=TagCategory.GYM_SERVICE), required=False ) activities = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Tag.objects.filter(category=TagCategory.GYM_ACTIVITY), required=False ) @admin.register(Gym) class GymAdmin(TranslatableAdmin): inlines = [...] form = GymForm Which gets rendered by the admin like this: Now I need to take all "Activities" and "Services" selected, clean their values by joining them together, and submit them as the single "tag_list" ManyToMany field in my model. How can I do this? Thank you for your time! -
Adding images created from Pillow to a single Django object
I have an wrote a small app that takes a single .gif as an upload and it splits the gif into frames using Pillow. I'm saving the .gif through a Document model and the frames through DocumentImage model. Currently, the app saves the .gif object and creates one object for each frame. What I want is all the frames be saved into a single object and that object be linked to the gif object. Here's what I have so far: views.py def create_gif(uploadedFile): # create a folder if it doesn't exist try: gif = Image.open('media/' + uploadedFile) print() except: print('Not OK') frames = [frame.copy() for frame in ImageSequence.Iterator(gif)] i = 0 while (i < len(frames)): buffer = BytesIO() frames[i].convert('RGB').save(fp=buffer, format='JPEG') finalImage = InMemoryUploadedFile(buffer, None, os.path.basename(uploadedFile)[:-4] + str(i) + '.png', 'image/jpeg', frames[i].tell, None) imageToSave = DocumentImage(imagefile=finalImage) imageToSave.save() i += 1 def list(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile=request.FILES['docfile']) if os.path.splitext(newdoc.docfile.name)[1].lower() != '.gif': messages.add_message(request, messages.INFO, "Please select a gif") else: newdoc.save() uploadedFile = newdoc.docfile.name create_gif(uploadedFile) messages.add_message(request, messages.INFO, "Saved") return HttpResponseRedirect(reverse('list')) else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() # Render … -
Connecting to a RADIUS Server using pyrad
In order to get my Django Backend Auth up and running, I've developed a small script that should connect to a radius SERVER: RADIUS_SERVER = 'abcs013p' RADIUS_SECRET = b'secret' RADIUS_DICTIONARY = "dictionary.txt" class RADIUS_Auth: def __init__(self, login, password): self.radius_authentication(login, password) def radius_authentication(self, login, password): client = Client(server=RADIUS_SERVER, secret=RADIUS_SECRET, dict=Dictionary(RADIUS_DICTIONARY)) # create request req = client.CreateAuthPacket(code=pyrad.packet.AccessRequest, User_Name=login) #NAS_Identifier="localhost"?? req["User-Password"] = req.PwCrypt(password) # send request reply = client.SendPacket(req) if reply.code == pyrad.packet.AccessAccept: print("access accepted") else: print("access denied") if __name__ == '__main__': RADIUS_Auth('PYMAT', 'London123') In my dictionary.txt I just have some simple text: letmein The first issue is, what details should I put for the NAS_Identifier, if any. Secondly, I receive a KeyError: 'User-Name' that gets thrown out when I try to create a request (the "req = " line). Can my script be improved somehow to at least get connectivity? -
ATTRIBUTE ERROR : AttributeError at /menu/register/ ----- 'function' object has no attribute 'objects'
Here's the full code. This error occurs when I try to build the login and register form! ERROR` AttributeError at /menu/register/ 'function' object has no attribute 'objects' Request Method: POST Request URL: http://127.0.0.1:8000/menu/register/ Django Version: 1.11 Exception Type: AttributeError Exception Value: 'function' object has no attribute 'objects' Exception Location: /Users/ambuj/Documents/GitHub/TrailPOS/pos/menu/forms.py in clean_username, line 70 Python Executable: /usr/bin/python Python Version: 2.7.10 Python Path: ['/Users/ambuj/Documents/GitHub/TrailPOS/pos', '/Library/Python/2.7/site-packages/Django-1.11-py2.7.egg', '/Library/Python/2.7/site-packages/twilio-6.3.dev0-py2.7.egg', '/Library/Python/2.7/site-packages/httplib2-0.10.3-py2.7.egg', '/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC'] Server time: Wed, 14 Jun 2017 10:44:22 +0000` My views.py from decimal import Decimal from django.contrib.auth import get_user_model from django.shortcuts import render, get_object_or_404 from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView from .models import dish from django.core.urlresolvers import reverse_lazy from .mixins import FormUserNeededMixin from .mixins import UserOwnerMixin from .models import category from .models import discount from .models import tax from .models import Cash from .models import Order from .forms import dishModelForm from .forms import categoryModelForm from .forms import discountModelForm from .forms import taxModelForm from .forms import UserRegisterModelForm import logging from django.http import HttpResponse from django.template import loader from django.core.exceptions import MultipleObjectsReturned from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic.edit import FormView import json # Create your views here. User = … -
Why the filter isn't work?
I want to filter my product by country and brand, for that reason I have created a view: class CategoryView(ListView): template_name = '__index.html' context_object_name = 'products' paginate_by = 20 def get_queryset(self): queryset = Product.objects.filter(category__slug=self.kwargs.get('slug')).order_by('-created') request = self.request # Filter By Brand and Country if request.GET.get('country'): print(request.GET.get('country')) queryset.filter(brand__country__slug=request.GET.get('country')) if request.GET.get('brand'): print(request.GET.get('brand')) queryset.filter(brand__slug=request.GET.get('brand')) print(queryset[0].brand.slug) print(queryset[0].brand.country.slug) return queryset But products isn't filtering when i pass querystring like that: ?brand=astra-gold&country=chehiya and print function show me: chehiya astra-gold veneto italiya As you can see chehiya != italiya and astra-gold != veneto. Bun why this happen? -
django - How can I filter in serializer
class User(generics.RetrieveAPIView): serializer_class = RetrieveLocalSerializer queryset = User.objects.filter( fields_1=True, fields_2=False ) class LocalSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('field_1', 'field_2', 'field_3',) The API did not work as it I wish. When I tried get user that does not have the property i want, it still returned the result. I even tried override that function but it did not work too. def get_queryset(self): return User.objects.filter( is_localguide=True, state=PROFILE_STATE.PUBLISHED ) Any help is appreciated. -
Failing to save form's data to different models
I am new to django and I have the following code snippet. What I am trying to do here is get some form field's value, compare it to a string and if matches found then save the value in a different Model. def log_name_insert(request): if 'logged_in' in request.session: if request.session['logged_in'] is True: form = LogEntryForm(request.POST or None) phaseform = PhaseNameForm(request.POST or None) testForm = TestTypeForm(request.POST or None) priorityForm = PriorityNameForm(request.POST or None) frequencyForm = FrequencyNameForm(request.POST or None) statusForm = StatusNameForm(request.POST or None) defectSeverityForm = DefectSeverityNameForm(request.POST or None) causeCategoryForm = CauseCategoryNameForm(request.POST or None) leakagePhaseForm = LeakagePhaseNameForm(request.POST or None) testStatusForm = TestStatusNameForm(request.POST or None) # print(form) if form.is_valid() and phaseform.is_valid() and testForm.is_valid() and priorityForm.is_valid() and frequencyForm.is_valid() and defectSeverityForm.is_valid() and causeCategoryForm.is_valid() and leakagePhaseForm.is_valid() and testStatusForm.is_valid() and statusForm.is_valid(): if LogEntry.objects.filter(log_name_add=request.POST['log_name_add']).exists(): print("entry found") else: form.save() print(form.cleaned_data['log_name']) if form.cleaned_data['log_name'] == "Phase": print(form.cleaned_data['log_name']) obj = PhaseList() phaseform.cleaned_data['phase_name'] = form.cleaned_data['log_name_add'] obj.phase_name = phaseform.cleaned_data['phase_name'] obj.save() if form.cleaned_data['log_name'] == "Test Type": obj = TestTypeList() testForm.cleaned_data['test_type'] = form.cleaned_data['log_name_add'] obj.test_type = testForm.cleaned_data['test_type'] obj.save() if form.cleaned_data['log_name'] == "Priority": obj = PriorityList() priorityForm.cleaned_data['priority_name'] = form.cleaned_data['log_name_add'] obj.priority_name = priorityForm.cleaned_data['priority_name'] obj.save() if form.cleaned_data['log_name'] == "Frequency": obj = FrequencyList() frequencyForm.cleaned_data['frequency_name'] = form.cleaned_data['log_name_add'] obj.frequency_name = frequencyForm.cleaned_data['frequency_name'] obj.save() if form.cleaned_data['log_name'] == "Status": obj = StatusList() statusForm.cleaned_data['status_name'] = form.cleaned_data['log_name_add'] obj.status_name … -
django - admin model assign value to limit_choices_to from another field inside the model
I have extended the admin model, so for each staff member i can assign other customers only if they are in the same group. class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) is_manager = models.BooleanField(default=False) group_account = models.CharField(max_length=3,blank=True,null=True) clients_assigned = models.ManyToManyField(User, limit_choices_to = Q(groups__groupaccount__group_account=group_account),blank=True,null=True,related_name='+') class UserProfileInline(admin.StackedInline): model = UserProfile verbose_name = "User extra" verbose_name_plural = "extra" filter_horizontal = ('clients_assigned', ) def save_model(self, request, obj, form, change): return super().save_model(request, obj, form, change) class UserAdmin(BaseUserAdmin): inlines = [UserProfileInline, ] def get_form(self, request, obj=None, **kwargs): #permissions reduce for regular staff if (not request.user.is_superuser): self.exclude = ("app") self.exclude = ("user_permissions") ## Dynamically overriding #self.fieldsets[2][1]["fields"] = ('is_active', 'is_staff','is_superuser','groups') self.fieldsets[2][1]["fields"] = ('is_active', 'is_staff') form = super(UserAdmin,self).get_form(request, obj, **kwargs) return form and extended the group admin model class GroupAccount(models.Model): group_account = models.CharField(,max_length=3,blank=True,null=True) group = models.OneToOneField(Group,blank=True,null=True) def save(self, *args, **kwargs): super(GroupAccount, self).save(*args, **kwargs) what im trying to do is simply to limit the client list for each manager-user by his and their group indicator(group_account field), means the available client list are those whom have the same specific group as himself, such as '555' when the group_account = '555' in the DB the result of groups__groupaccount__group_account=group_account are empty but if i change it Hardcoded to: groups__groupaccount__group_account='555' its return the relevant result. … -
User authentication fail for POST method in TastyPie
I am using Tastypie (django-tastypie-0.9.11) with Django 1.4.For authentication I am using TastyPie's BasicAuthentication. Passing Authorization token in headers as headers = {'Authorization': 'Basic xyzwlhkhkg'} So, while debugging the code I noticed, the same header create a user object only when the request method if 'get' but user object is not getting created in case of post method. My problem is why it's not getting authenticated in case of the post. I tried using csrf_exempt still it doesn't solve the problem. Can anyone please help. -
ordering queries based on most upvotes
I want to order my query based on the number of upvotes but I can't figure out how to do it. It seems way too complex! ( btw am I over-complicating things?) so here is my models.py class Activity(models.Model): FAVORITE = 'F' LIKE = 'L' UP_VOTE = 'U' DOWN_VOTE = 'D' FOLLOW = 'W' REPORT = 'R' ACTIVITY_TYPES = ( (FAVORITE, 'Favorite'), (LIKE, 'Like'), (UP_VOTE, 'Up Vote'), (DOWN_VOTE, 'Down Vote'), (FOLLOW, 'Follow'), (REPORT, 'Report') ) user = models.ForeignKey(User) activity_type = models.CharField(max_length=1, choices=ACTIVITY_TYPES) date = models.DateTimeField(auto_now_add=True) # Below the mandatory fields for generic relation content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey() class Entry(models.Model): text = models.TextField(default='') time_created = models.DateTimeField(auto_now=False, auto_now_add=True) time_updated = models.DateTimeField(auto_now=True, auto_now_add=False) created_by = models.ForeignKey(User, on_delete=models.CASCADE) class Meta: abstract = True class QuestionManager(models.Manager): def by_topic(self, topic): ... def by_recent(self): ... def by_upvote_count(self): return self.all().order_by('-upvotes')[:5]\ .select_related('created_by','created_by__userprofile')\ .prefetch_related('question_comments','question_comments__reply',) class Question(Entry): objects = models.Manager() get = QuestionManager() activities = GenericRelation(Activity, related_query_name='questions') def calculate_votes(self, type): return self.activities.filter(activity_type=type).count() up_votes = property(calculate_votes, 'U') down_votes = property(calculate_votes, 'D') so, what I'm trying to do is to get by_upvote_count to return the top 5 upvoted items. I found the Count() method of the django.db.models but could get it to work with my set up, … -
Django form field, previous value
Is there a way to get form fields rendered value when form submitted in django. I may render form A field with value 1, User changes the A field value to 2 and submits. Form validation fails and I render A field with value 2 again. User changes the value of A field to 3 and submit. I want to see that value is 3 and previous value is 2. -
Handle a pdf response from API in Django
I would like to know how I can display a pdf in my template. I'm using the python library requests to get the response from an external API. In the get request the API sends me a pdf, but I do not know how to handle it to show it in the template. -
How do I return an error message to html page in django?
Now I am using this format messages.error(request,"error message") but I want to return this error message to test.html instead of request messages.error('test.html',"error message") Anybody has idea? -
Refreshing div using ajax in a django template
I've tried implementing solutions in couple of similar questions. But none of them worked for me. I'm new to django. I'm trying to build an app which fetches whois records. My template file is : <form action = "{% url 'whoisrec:index' %}" method = "post"> {% csrf_token %} <input name = "domain" type = "text" value = "{{domain}}" /> <input type = "submit" value = "Go" /> </form> <div id = "result"> {{text|linebreaks}} </div> I need to refresh "result" div each time new domain is entered instead of refreshing the whole page. The script I'm using : <script> $(document).ready(function() { $("button.add-comment-button").click(function() { $.ajax({ url: '{% url 'whoisrec:index' %}', success: function(data) { var html = $(data).filter('#result').html(); $('#result').html(html); } }); }); }); </script> My view: def index(request): try: domain = request.POST['domain'] requested = True except: return render(request, 'whoisrec/index.html') requested = False w = whois.whois(domain) text = w.text context = { 'domain' : domain, 'text' : text, 'flag' : requested } return render(request, 'whoisrec/index.html',context) -
How to use a variable in views.py inside a template in Django?
I have a variable in the file views.py of my app directory. I need to print that variable inside my template. How can I do That? -
django lazy fetching not working?
I have 3 models news mappings,news likes and news pokes which are described below: from __future__ import unicode_literals from django.db import models from cms.models.boards import Boards from cms.models.news import News # WE ARE AT MODELS/NEWS MAPPINGS class NewsMappings(models.Model): id = models.IntegerField(db_column="id", max_length=11, help_text="") newsId = models.ForeignKey(News, db_column='newsId', max_length=11, help_text="") boardId = models.ForeignKey(Boards, db_column='boardId', max_length=11, help_text="") isWallPost = models.BooleanField(db_column="isWallPost", default=False, help_text="") masterPostTypeId = models.IntegerField(db_column="masterPostTypeId",max_length=11,help_text="") class Meta: managed = False db_table = 'news_mappings' from __future__ import unicode_literals from django.db import models from cms.models.appUsers import Users from cms.models.newsMappings import NewsMappings class NewsLikes(models.Model): id = models.IntegerField(db_column="id", max_length=11, help_text="") userId = models.ForeignKey(Users, db_column='userId', max_length=11, help_text="") newsId = models.ForeignKey(NewsMappings, db_column='newsMappingId', max_length=11, help_text="") createdAt = models.DateTimeField(db_column='createdAt', auto_now=True, help_text="") class Meta: managed = False db_table = 'news_likes' from __future__ import unicode_literals from django.db import models from cms.models.appUsers import Users from cms.models.newsMappings import NewsMappings from cms.models.masterPokes import MasterPokes class NewsPokes(models.Model): id = models.IntegerField(db_column="id", max_length=11, help_text="") userId = models.ForeignKey(Users, db_column='userId', max_length=11) newsMappingId = models.ForeignKey(NewsMappings, db_column='newsMappingId', max_length=11) masterPokeId = models.ForeignKey(MasterPokes, db_column='masterPokeId', max_length=11) otherPoke = models.CharField(db_column='otherPoke', max_length=255) createdAt = models.DateTimeField(db_column='createdAt', auto_now=True, help_text="") class Meta: managed = False db_table = 'news_pokes' in my templates i am passing NewsMapping objects. I am using newsMapping = NewsMappings.objects.all() and passing newsMapping in contex as datalist.And Applying … -
DRF + React/Redux retyrning payload as undefined
I'm using DRF and React + Redux. I'm trying now to fetch data from the client, which is ReactJS + Redux, but it always returns payload as undefined. The endpoint is categories. It is set up within the project's urls.py, which includes the categories.urls: url(r'^categories/', include("categories.urls")), ... url(r'^$', views.CategoryList.as_view(), name="categories_view"), My project's structure is the following: project/ api/ -> Django webroot/ -> ReactJS/Redux In API, the Category model: class Category(models.Model): name = models.CharField(max_length=32, unique=True) created_at = models.DateTimeField(default=timezone.now) updated_at = models.DateTimeField(default=timezone.now) def __str__(self): return self.name Its CategorySerializer: class CategorySerializer(serializers.ModelSerializer): class Meta: model = models.Category fields = ('name',) name = serializers.CharField(required=True, max_length=32) def create(self, validated_data): return models.Category.objects.create(**validated_data) def update(self, instance, validated_data): pass And the CategoryList: class CategoryList(APIView): renderer_classes = (JSONRenderer,) def get(self, request, format=None): """ Get all categories :param request: :param format: :return: """ categories = Category.objects.all() serializer = CategorySerializer(categories, many=True) return Response(serializer.data) def post(self, request, format=None): """ Creates a category :param request: :param format: :return: """ pass Then, in the client side, my action: export function categoryList() { return { [CALL_API]: { endpoint: '/api/categories', method: 'GET', types: [CATEGORY_LIST, CATEGORY_LIST_SUCCESS, CATEGORY_LIST_FAILURE], }, } } ... const ACTION_HANDLERS = { [CATEGORY_LIST]: state => ({ ...state, fetchingCategories: true, fetchingCategoriesSuccess: false, }), [CATEGORY_LIST_SUCCESS]: (state, action) … -
Getting error while trying to implement login application using Django
I am facing one issue. I am trying to implement login/logup application using Django but in login page I am getting the below error. TemplateDoesNotExist at /login/ login.html Request Method: GET Request URL: http://127.0.0.1:8000/login/ Django Version: 1.11.2 Exception Type: TemplateDoesNotExist Exception Value: login.html Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/loader.py in select_template, line 53 Python Executable: /usr/bin/python Python Version: 2.7.6 I am explaining my login.html page below. {% extends 'base.html' %} {% block title %}Login{% endblock %} {% block content %} <h2>Login</h2> <form method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit">Login</button> </form> {% endblock %} urls.py: from django.conf.urls import url from django.contrib import admin from django.contrib.auth import views as auth_views from django.views.generic.base import TemplateView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'), url(r'^login/$', auth_views.login, {'template_name': 'login.html'}, name='login'), url(r'^logout/$', auth_views.logout, {'template_name': 'logged_out.html'}, name='logout'), ] Please help me to resolve this error. -
OneToOneField to abstract model
I'm looking to create a database structure where each Group has a link to a single Policy. A Policy can be one of a variety of different types, each of which:- may have extra attributes will definitely have a method called do_this() and one called do_that() Over time, more Policys will be created, each with their own attributes etc. My initial instinct with this was to go with Policy being an abstract class with a link back to the Group and stubs for the methods:- class Policy(models.Model): group = models.OneToOneField(Group) class Meta: abstract = True def do_this(): raise NotImplementedError() def do_that(): raise NotImplementedError() Then different policy types can add their own attributes but they have to implement the interface. class PolicyA(Policy): new_attribute = models.IntegerField() def do_this(): # implementation A def do_that(): # implementation A But if I do that, then I have no way of asking a Group for it's Policy, as Policy is abstract. If I remove the abstract setting, then (using something like django model utils, I guess) I can get the "real" type of the Policy at runtime but that doesn't feel right to me. I've read up a bit on generic relations but is that the … -
How can i have multiple forms on a django template
I am absolutely new to django and python and i have the following question: I want to have two Forms on a single page. Each form should have a own submit button which triggers a different background process. I already read that i shoul have one view for each form. But how can i use two views with one template? ( i am currently using Django 1.7) -
connecteing android app to django web server's postgresql on heroku
I have deployed a web server on heroku based on django framework and connected to heroku's postgresql. Now I am building an android application that authenticates data from server for instance there is a login form. On searching I have found that making a HTTP request by android can work but it is a bit unclear to me still. I have following queries in mind. I am using auth users in my web app and built in login functionality so do I have to create a separate django view that accepts HTTP request and respond accordingly? If yes how do I authenticate? The android should make a post request? passing username and password? I am new in android so don't know much about it. Kindly guide me what should I do. -
Failure installing Pillow on ubuntu 14.04
i tried installing pillow on my ubuntu 14.04, i get the following error message. Should I install it with easy_install? because I've heard the pip doesn't work that much. please any suggestions? Or is there I need to install prior to running the command pip install pillow running egg_info writing dependency_links to Pillow.egg-info/dependency_links.txt writing requirements to Pillow.egg-info/requires.txt writing Pillow.egg-info/PKG-INFO writing top-level names to Pillow.egg-info/top_level.txt warning: manifest_maker: standard file '-c' not found reading manifest file 'Pillow.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*.sh' no previously-included directories found matching 'docs/_static' warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.editorconfig' warning: no previously-included files found matching '.landscape.yaml' warning: no previously-included files found matching '.travis' warning: no previously-included files found matching '.travis/*' warning: no previously-included files found matching 'appveyor.yml' warning: no previously-included files found matching 'build_children.sh' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files matching '.git*' found anywhere in distribution warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution writing manifest file 'Pillow.egg-info/SOURCES.txt' running build_ext The headers or library files could not be found for zlib, a required dependency when compiling Pillow …