django

cappuccino django integration

Hi does anyone integrated cappuccino with django. I wanted to use cappuccino as a front-end and django as a backend and communicate via CFHTTPRequest / Json. I did the following: copy the the cappuccino app to the templates folder of my django app. Then used a render_to_response to the index.html generated by cappuccino. Unfortunately ...

Django error: 'NoneType' object is not subscriptable

It's taking me way to long to make this simple form. Almost there but when I submit I get the NoneType error views.py: from djangoproject1.authentication import forms from django.contrib.auth.models import User from django.http import HttpResponseRedirect from django.shortcuts import render_to_response def main(request): rf = for...

Django (wsgi) and Wordpress coexisting in Apache virtualhost

I have a Django project that I need mounted at two different subdirectories of my url, and I need Wordpress running at /. So: *.example.com - WordPress *.example.com/studio - django *.example.com/accounts - django Here's the httpd.conf that I have so far: <VirtualHost *:80> ServerName wildcard.localhost ServerAlias *.localhos...

Django - how to access fields in a customized many-to-many through object in templates

Consider the following models: class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.Forei...

Django and Eclipse, making a portable project

I like Eclipse for a number of reasons. One of them is, when I'm doing a java project, I can copy and paste my project or rename it, to make a new one, and it will update all the names of everything. I'm trying to do something similar for a django project. I can set an APPNAME variable with the following code APPNAME = os.path.basena...

Random/non-constant default value for model field?

I've got a model that looks something like this class SecretKey(Model): user = ForeignKey('User', related_name='secret_keys') created = DateTimeField(auto_now_add=True) updated = DateTimeField(auto_now=True) key = CharField(max_length=16, default=randstr(length=16)) purpose = PositiveIntegerField(choices=SecretKeyPur...

Select Children of an Object With ForeignKey in Django?

I'm brand new to Django, so the answer to this is probably very simple. However, I can't figure it out. Say I have two bare-bones Models. class Blog(models.Model): title = models.CharField(max_length=160) text = models.TextField() class Comment(models.Model): blog = models.ForeignKey(Blog) text = models.TextField() I...

Can model properties be displayed in a template

I am looking to display a model property in a template, which uses an inlineformset_factory. Is this even possible? I have not come across any example. I am trying to display 'json_data' in my template class RecipeIngredient(models.Model): recipe = models.ForeignKey(Recipe) ingredient = models.ForeignKey(Ingredient) serving...

Where do I set my site url in django settings?

Ok I think I must be missing something. In settings.py I don't see the local setting for absolute url for the site. I see there is a media_url. In django registration it references {{ site }} which is defaulting to example.com but I'm not seeing that in any settings. If I want the dev.mysite.com and mysite.com to work independently?...

django modelform css class for select

Hi. I am trying to add in a class with the name of autocomplete into one of my select. class MyForm(ModelForm): class Meta: model = MyModel exclude = ['user'] def __init__(self, user, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) self.fields['specie'].queryset = Specie.objects....

Cannot create new Django model object within Ajax post request

This is kind of "I already lost x hours debugging this" kind of problem/question :( Following jQuery js code is initiating POST request upon button click $("#btn_create_tag").click(function(evt) { $.post("/tag/createAjax", { tagname: $("#txt_tag_name").val() }, function(data) { } ); }); Django code that is per...

Admin site automatically get current user

I am making a blog application and want to automatically add the current user when i submit a new post through the admin site. Is there any way that i could detect the current logged-in user and add it to the post. These are the models: class Post(models.Model): user = models.ForeignKey(User) title = models.CharField('Title', ma...

Processing dynamic MultipleChoiceField in django

All the answers I've seen to this so far have confused me. I've made a form that gets built dynamically depending on a parameter passed in, and questions stored in the database. This all works fine (note: it's not a ModelForm, just a Form). Now I'm trying to save the user's responses. How can I iterate over their submitted data so I c...

Name URL is re-written as IP by something? nginx, apache, django?

I am using django, nginx and apache. When I access my site with a URL (e.g., http://www.foo.com/) what appears in my browser address is the IP address with admin appended (e.g., http://123.45.67.890/admin/). When I access the site by IP, it is redirected as expected by django's urls.py (e.g., http://123.45.67.890/ -> http://123.45.67.890...

Django admin search: how to override the default handler?

I wish to customize the way in which search queries across the search_fields. Is there a way to do it without hacking deeply into the Django code or creating a totally independent view? For instance, I would like to return the union of the querysets for each of the items of the querystring.split(). So that searching for "apple bar" wou...

Using Cython with Django. Does it make sense ??

Hello Everyone, Is it possible to optimize speed of a mission critical application developed in Django with Cython Sorry in advance if it doesn't make sense......as i am new to django. Recently i have read on the internet that you can use cython and turn a python code to c like speed......so i was wondering is this possible with djan...

django-signals vs triggers?

I read about django signals (http://docs.djangoproject.com/en/dev/topics/signals/), but as far as I understand, signals are never converted into literal SQL triggers (http://en.wikipedia.org/wiki/Database_trigger). If I'm correct that signals and triggers are different, then which one is better and in what ways? What's the best practice...

Serve static files through a view in Django

Hello, I am writng a Django application that let's you download a file after some requirements have been met (you have to log on, for example). The file needs to be inaccessible otherwise. Serve the file through Apache won't work: I have to check in the database for the user's permissions. Furthermore, don't have permission to change ...

Unable to set custom permissions in Django

Hi, I'm trying to setup some custom permissions for a Django application, but can't seem to get it working. The official documentation is a little scant, and doesn't mention (at least that I can find) how to actually set a permission? Based on a few 3rd party tutorials I found, I've extended the User class and it seems to work OK: from...

Django and Eclipse, console

I'm using Django with Eclipse and I figured out you can start and stop the server through Eclipse and the output appears in the console. This is great except that there's a delay between when the event happens, and when the result appears. Usually, in order to get something to show up on the console I have to make a change to the code ...