Django relies on frame authentication

I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies

ModelViewSet - Hide fields selectively?

I have an Instructor model, which has a many to many field to a Client model. (Instructor.clients) The model: class InstructorProfile(models.Model): '''Instructor specific profile attributes ''' # Fields office_number = models.CharField(max_length=30

How to check if the Django object is None in javascript?

How do you check if a Django object is None in js? I currently have a variable person that stores a Django object or None. In my js I have: if ({{person}} != None) { execute_function({{person}}) } What seems to be the issue here?John Smiths answer ma

Django submit the form without updating the page

I'm using Django-Angular and trying to post a form and obtain data in back-end..I'm able to achieve this but found that the page is reloading while saving the form. How can we achieve the same without page render? forms.py def home(request): if 'appl

Time limit in the django model

I need a help with time-limit. I want to show user how many time he has got to rent a car. This is my views: class CarRentView(RedirectView): permanent = False query_string = True model = Car def date_of_return(request): car = Car.objects.all() car.r

Define the custom tag of the django model on the fly

Is there a way in django to declare a custom template tag "on the fly"? For example, if I have a page that renders an a tree structure and for my tag to work, it needs the root and the leaf. Since I now that I will use this tag only with this ro

The Django model method will not update the model field

I have a model object with a two methods: expired and pending. The expired manager works fine and updates the field. The pending manager does not work. Here is my code. Side note: I set pending to true in a view. models.py: class Job(models.Model): e

Django + Apache - wsgi problem

I've been working with Django locally and now I'm trying to push some code to a production Apache environment on an Ubuntu server I have running (http://www.youtube.com/watch?v=hBMVVruB9Vs). However, I just get a list of files in the directory and no

Django Abstract Pattern Inheritance

In a model I usually put a "uuid" field for friendly URI, also a "slug" field. Say I have a model named "SomeModel", by overriding its save() method, I can generate a uuid and a slug when it's being saved: class SomeModel(mod

Django Querying Relationship Relationship

I'm stuck on a Django ORM issue that is bugging me. I have a set of models linked by a foreign key but the requirements are a bit odd. I need to list items by their relation's relation. This is hard to explain so I've tried to depict this below, give

No module named theme.urls

I just deployed my first django app to the Heroku platform. I basically followed this tutorial, just that instead of creating a dummy django-admin.py startproject hellodjango . django app, I used my app that currently works on my Windows PC. When dep

Django empty error messages

I have an ajax login view. I can log in ok but when I log in incorrectly my json returns: {"errors": {}} My view is as follows: def ajaxlogin(request): from forms import LoginForm form = LoginForm(request.POST) logged_in = False username = reque

Django query for 3 tables

I have the following model structure Country, City(fk=country) and School(fk=city). Now I want to get list of countries with city, if city has a school. In my template, I want to do for country in countrylist for city in getcitieswithschool Can I get

Django: How to register a formset with a custom template form?

Trying to save a bunch of objects but with a custom form: class CustomForm(forms.ModelForm): class Meta: model = Widget complexify = models.BooleanField() When complexify is checked, i need to do some complex operations on the widget object. I can't

Django overhead pagination with sorting

I try to implement pagination structure in Django with some sort options however, I can't figure out how can I do that properly. views.py def search(request): eList = Employer.objects.filter(eminence__lt=4).order_by('-eminence') paginator = Paginator

How to use Httpresponse in view in django using Ajax

I am using this def ajax_create( request ): if request.is_ajax(): form = SourceForm() template = 'ajax_form.html' data = { 'form': form, } return render_to_response( template, data, context_instance = RequestContext( request ) ) I get this error ajax

Get foreignkey queryset

I need to obtain a queryset of a foreignkey but I haven't been able to figured out how. I have the following model: class Contact(models.Model): owner = models.ForeignKey(CustomUser, related_name='contact_set') referenced = models.ForeignKey(CustomUs

How to keep all my django apps in a specific folder

I have a Django project, let's say "project1". Typical folder structure for applications is: /project1/ /app1/ /app2/ ... __init__.py manage.py settings.py urls.py What should I do if I want to hold all of my applications in some separate folder

Django for a simple web application

I'm developing an app (an API) in python and I would like to offer some of its functionality through a web interface (like web services do). I've been looking at django, but I don't know if really fits well in my idea. I only want to create a web pag

django url - link problem

i have an application, and in my urls.py i have something like that: urlpatterns = patterns('', url(r'^profile_view/(?P<id>\d+)/$', profile_view, name='profile_view'),) meaning that the profile_view function has id as a parameter. Now, i want to cal

Add a field to the template, such as annotate

For example, I have a model Posts and Comments. Post.objects.annotate(Count('comment')) I am making such query to get count of comments for every post. But in template i should check if this value greater than 4. As I know there is no such templateta

Django and Sqlite competition problem

I've done a bit of reading related to the concurrency issues with sqlite, but I don't see how they'd apply to Django since it's inherently single threaded. I'm not using any multiprocess modules either. I have absolutely no experience with concurrent