Search Posts

Category: django

Login button won’t fire

how to Login button won’t fire I’m using Django and AngularJS in a log in form. In this case, the username is in email format. My login form’s button will only become un-disabled when the user enters a string formatted like an email address and a password of at least eight characters. But clicking the login button does nothing. Nothing fires. No POST request is made. class LoginForm(AuthenticationForm): ”’ Form to log in a […]

Error template when using {%djng_all_rmi %} – django + AngularJs

how to Error template when using {%djng_all_rmi %} – django + AngularJs I’m using django 1.1.10 with Angularjs to developping my first app . according to this document : when using this code : {­% load djng_tags %­} … <script type=”text/javascript”> var tags = {­% djng_all_rmi %­}; my_app.config(function(djangoRMIProvider) { djangoRMIProvider.configure(tags); }); </script> i get this error : enter image description here Thanks for your help ! Source: AngularJS

How to send image as input to django view using angular frontend?

I have an existing django web api with angular frontend, using which i can upload images and display them to the user.Now i want to extend this.On clicking the button “segment”(see image) it should pass the corresponding image to my python script on the backend, which does some processing on the image. I have my python script in the file of the main app,which is some thing like this: from django.shortcuts import render def […]

How to re-sort search results in-place without having to re-send a request in django?

Here is the scenario: I have a search page, with some form elements providing multiple filter conditions (something like ‘advanced search’), and probably a nested ListView to display the search results in-place. What I would like to achieve: Whenever the user changes some filter conditions, the result list below responds in-place (taking another request for this could be accepted); When the user changes the sorting option, the results change their ordering immediately, without sending another […]

Loading angular data from another html template

Quite a newbie with angular and having trouble with integrating it with django and the form generator. I’m trying to display a form done through easyformgenerator. This form makes use of angular to show the data, and I’m trying to display everything through calling another html template. This is my button to call the function: <a onclick=”viewResponse(this)” id=”{{fbuilder.uuid}}” role=”button” class=”btn btn-success btn-sm pull-right”> <i class=”fa fa-fw fa-plus”></i> New Response </a> My viewResponse function: function viewResponse(item) […]

Escape additional characters with Django autoescape

I’m trying to extend Django default autoescape behavior to escape the {} characters. The issue is our Django templates are printing inline JS templates (angular.js). But this means some variable django prints might contains {{}} characters that are going to be executed – thus allowing XSS. We’re usually doing escapes and backend validation, but some old pages might’ve skipped the basic checks. Any chance we can hook directly in the autoescape behavior to also HTMl […]

Angular unexpected token return

I’m trying to integrate easyformgenerator in my django project, but when I attempt to create the controller, I get an error saying ‘Uncaught SyntaxError: Unexpected token return’ this is how I’m doing it // forms var formApp = angular.module(‘formApp’, [‘eda.easyFormViewer’]); formApp.config([‘$httpProvider’, function($httpProvider) { $httpProvider.defaults.xsrfCookieName = ‘csrftoken’; $httpProvider.defaults.xsrfHeaderName = ‘X-CSRFToken’; }]) formApp.controller(‘formCtrl’, [‘$scope’, ‘$http’, function ($scope, $http) { $scope.forms = form; $scope.viewHistory = function(element) { $http({ method: ‘GET’, url : ‘{% url “employee:ajax-view-responses” %}’ + “?fid=”+element+”&eid=”+employee, […]

Django REST framework custom format for all out responses

In my project I use DRF as backend and Angular as frontend. Django==1.10 djangorestframework==3.7.1 I need all responses from DRF to be in the following format. { “status”: “”, // 200,400,…..etc “error”: “”, // True, False “data”: [], // data “message”: “” // Success messages } for this i have written a custom viewset and overridden the functions list, detail, create, update class ResponseModelViewSet(viewsets.ModelViewSet): def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) page = self.paginate_queryset(queryset) […]

Django RestAuth Custom password reset link

I have tried the solutions I found for a similar question but none worked for me. I am using an angular frontend + DRF + Django Rest Auth, for the confirmation url, I was able to override it to point to my frontend by adding a custom adapter that looks liked this, class AccountAdapter(DefaultAccountAdapter): def send_mail(self, template_prefix, email, context): context[‘activate_url’] = settings.URL_FRONT + ‘access/verify-email/’ + context[‘key’] msg = self.render_mail(template_prefix, email, context) msg.send() with URL_FRONT = […]

Next Page »