django

Reverse Not Found: Sending Request Context in from templates

N.B This question has been significantly edited before the first answer was given. Hi, I'm fairly new to django, so apologies if I'm missing something obvious. I've got a urls.py file that looks like this: urlpatterns = patterns( '', (r'^$', 'faros.lantern.views.home_page'), (r'^login/$', 'django.contrib.auth.views.login'...

Python/Django Modeling Question

What is the best way to have many children records pointing to one parent record in the same model/table in Django? Is this implementation correct?: class TABLE(models.Model): id = models.AutoField(primary_key=True) parent = models.ForeignKey("TABLE", unique=False) ...

Unable to start a django server in my computer

I exported the path of my django project by $ export DJANGO_SETTINGS_MODULE=/Users/masi/Documents/Test/djangobook/ch3.settings I run unsuccessfully $ django-admin.py runserver Error: Could not import settings '/Users/masi/Documents/Test/djangobook/ch3.settings' (Is it on sys.path? Does it have syntax errors?): Import by filename is ...

Unable to find the Python module execute_manager in django.core.management

Problem: to find the Python module execute_manager in the class django.core.management. The question is related to another question of mine. I am trying to start my server by python manage.py runserver The command is dependent on manage.py. The file imports the module execute_manager from the class django.core.management as follows...

form with CheckboxSelectMultiple doesn't validate

I have a form with a choice field that is using CheckboxSelectMultiple widget: foo = forms.ChoiceField(widget=forms.CheckboxSelectMultiple, choices=( ("1", "ONE"), ("2", "TWO"), )) The form renders fine showing ...

Django pagination and "current page"

I'm currently developing a Django application which will make use of the infamous "pagination" technique. I'm trying to figure out how the django.core.paginator module works. I have an application with a Question model. I will be listing all of the questions using this paginator. There will be 20 questions per page. def show_questio...

benchmarking django apps

I'm interested in testing the performance of my django apps as I go, what is the best way to get line by line performance data? note: Googling this returns lots of people benchmarking django itself. I'm not looking for a benchmarks of django, I'm trying to test the performance of the django apps that I'm writing :) Thanks! edit: By "l...

Group models in django admin

Is there any way to group the models in django admin interface? I currently have an app called requests with the following models showing in the admin site: **Requests** Divisions Hardware Requests Hardware Types Requests Software Requests Software Types I would like the divisions, Software Requests and Hardware Requests to be groupe...

Django: How to use stored model instances as form choices?

I have a model which is essentially just a string (django.db.models.CharField). There will only be several instances of this model stored. How could I use those values as choices in a form? To illustrate, the model could be BlogTopic. I'd like to offer users the ability to choose one or several topics to subscribe to. I started writing...

Django Passwords

You know how django passwords are stored like this: sha1$a1976$a36cc8cbf81742a8fb52e221aaeab48ed7f58ab4 and that is the "hashtype $salt $hash". My question is, how do they get the $hash? Is it the password and salt combined and then hashed or is something else entirely? ...

Need help choosing a framework for bilingual site

First, some background information... I'm coming up on a medium-scale website for a non-profit that will require both English and Korean translations. Feature-set includes: CMS for normal content, a blog, some form submission/handling (including CSV/PDF exports), a job posting board, a directory of related businesses and non-profits (tha...

How would I do this without an explicit SQL JOIN?

I have a model called Question and another one called Answer. class Question(models.Model): text = models.CharField(max_length=140) class Answer(models.Model): user = models.ForeignKey(User) question = models.ForeignKey(Question) uncertain = models.BooleanField() text = models.CharField(max_length=30) Now I'd lik...

Any thoughts on A/B testing in Django based project?

We just now started doing the A/B testing for our Django based project. Can I get some information on best practices or useful insights about this A/B testing. Ideally each new testing page will be differentiated with a single parameter(just like Gmail). mysite.com/?ui=2 should give a different page. So for every view I need to write a...

How do you order lists in the same way QuerySets are ordered in Django?

I have a model that has an ordering field under its Meta class. When I perform a query and get back a QuerySet for the model it is in the order specified. However if I have instances of this model that are in a list and execute the sort method on the list the order is different from the one I want. Is there a way to sort a list of in...

Manipulating Data in Django's Admin Panel on Save

Ok, so here's the skinny: # models.py class Article( models.Model ): title = models.CharField( max_length = 255 ) author = models.ForeignKey( User ) published_at = models.DateTimeField( auto_now_add = True ) body = models.TextField( ) def __unicode__( self ): return self.titl...

Django Middleware + URL's

Can a middleware check to see if a value is in the url, such as an image id ("/image/152/"), and if it is then do some checks to make sure the current user has permission to view that image and if not redirect to another url? I had to roll my own permissions for this site I am working on and I don't want to clog up almost every view I w...

Default value for field in Django model

Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.CharField(max_length=10) b = models.CharField(max_length=7) Currently I am using the defauly admin to create/edit objects of this type. How do I remove the field b from the admin so that each object cannot be created w...

How do you serialize a model instance in Django?

There is a lot of documentation on how to serialize a Model QuerySet but how do you just serialize to json the fields of a Model Instance? ...

django-paypal setup

Has anyone setup django-paypal? Here is the link to it: [here][1]? I have "myproject" setup, and my folder sturecture looks like this: myproject > paypal > (stdandard and pro folders) to my settins.py file I added INSTALLED_APPS = ( 'myproject.paypal.standard', 'myproject.paypal.pro', ) in my url's file for my account app ...

filter for many to many field

so I have this model: class Message(models.Model): creator = models.ForeignKey(User, unique=True) note = models.CharField(max_length=200, blank=True) recipients = models.ManyToManyField(User, related_name="shared_to") read = models.ManyToManyField(User, related_name="read", blank=True) I want to filter on people who ar...