Suppose, I want to record say poll choices by users everyday. In this case, i have a table named vote which has columns poll , choice and user-id . So how can i out the constraint (maybe in the django models or wherever possible) that poll and user-id both should not be the same for any entry but like the same user can vote for various d...
I have some structure in Python:
> gender=( ('0','woman'), ('1','man') )
I want to translate it before I will display it in Django template. Unfortunately, below solution doesn't work:
> from django.utils.translation import
> ugettext_lazy as _
>
> gender=( ('0',_('woman')),
> ('1',_('man')) )
What shall I do to translate this? I ...
I am working on a django project and i want to send a signal when something get's added to some models related set, e.g. we have an owner wo has a set of collectables and each time the method owner.collectable_set.add(something) is getting called i want signal like "collectable_added" or something. signals are clear to me, but in which m...
Hay, i was wondering how i would go about setting up django so that i can send emails from a standard Leopard installation.
In php i just use mail() and it sends the mail for me.
Thanks
...
I have a class UserProfile defined which takes the default user as a foreign key.
Now another class A has a foreign key to UserProfile.
So for saving any instance in class A, how do i give it the userprofile object.
Also, does making a class UserProfile mean that class user is still used and class UserProfile is just some other table?...
in symfony 2.0 and django there are bundles that contain everything for a feature (html, css, js, img, php/python).
so if you want to delete one feature, you basically just delete that bundle and unregister it from "main".
are there java frameworks for this too? or is it different in java cause java is a compiling language.
thanks
...
In my Django admin, when I try to view/edit objects from one particular model class the memory usage and CPU rockets up and I have to restart the server. I can view the list of objects fine, but the problem comes when I click on one of the objects. Other models are fine. Working with the object in code (i.e. creating and displaying) is o...
These are my models:
class Comment(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField(_('object ID'))
content_object = generic.GenericForeignKey()
user = models.ForeignKey(User)
comment = models.TextField(_('comment'))
class Post(models.Model):
title = models....
Hay, i was wondering how to get the current URL within a template.
Say my URL was
/user/profile/
How do i return this to the template?
Thanks
...
I want to create a user sign up process that requires two different forms with the same data one (1st form) is for filling out the data and other one (2nd form) is for displaying the filled data as a summery (before actually saving the data) so then user can view what he/she has filled up... my problem is that how do I pass 1st form's da...
So I created the following file (testlib.py) to automatically load all doctests (throughout my nested project directories) into the __tests__ dictionary of tests.py:
# ./testlib.py
import os, imp, re, inspect
from django.contrib.admin import site
def get_module_list(start):
all_files = os.walk(start)
file_list = [(i[0], (i[1], ...
I've got some models set up like this:
class AppGroup(models.Model):
users = models.ManyToManyField(User)
class Notification(models.Model):
groups_to_notify = models.ManyToManyField(AppGroup)
The User objects come from django's authentication system.
Now, I am trying to get all the notifications pertaining to the groups that the...
I'm working on a site that will help private teachers manage their students, and part of this will be keeping track of how much money the teacher is owed.
I want my apps to be reusable and free from dependency on one another. So, I've created one app whose responsibility is the CRUD of student, teacher, and parent objects (these models ...
I have 2 tables, simpleDB_all and simpleDB_some. The "all" table has an entry for every item I want, while the "some" table has entries only for some items that need additional information. The Django models for these are:
class all(models.Model):
name = models.CharField(max_length=40)
important_info = models.CharField(max_lengt...
Hi,
given a standard model (called Image) with an autoset 'id', how do I get the max id?
So far I've tried:
max_id = Image.objects.all().aggregate(Max('id'))
but I get a 'id__max' Key error.
Trying
max_id = Image.objects.order_by('id')[0].id
gives a 'argument 2 to map() must support iteration' exception
Any help?
...
i have the model:
class OpenCv(models.Model):
created_by = models.ForeignKey(User, blank=True)
first_name = models.CharField(('first name'), max_length=30, blank=True)
last_name = models.CharField(('last name'), max_length=30, blank=True)
url = models.URLField(verify_exists=True)
picture = models.ImageField(help_text...
Hi,
Sometimes, when submitting a form (pretty much any form on my site that sends me an email), I get the following error:
File "/usr/lib/python2.5/smtplib.py", line 603, in starttls
(resp, reply) = self.docmd("STARTTLS")
File "/usr/lib/python2.5/smtplib.py", line 378, in docmd
return self.getreply()
File "/usr/lib/python2.5/...
I'm getting into python for cgi and came across Django. I'm not quite sure I understand it very much. Is it something I have to install inside apache or is it just something I can use with my cgi?
Wanted to know because I'd love to learn it but my server I'm using doesn't give me a lot of privileges.
thanks
...
I have found myself writing the same view over and over. It is basically this:
def home_index(request):
return render_to_response('home/index.html', RequestContext(request))
To keep with the dry principal, I would like to utilize a generic view. I have seen direct_to_template, but it passes an empty context. So how can I use a g...
I am using the create_user() function that Django provides to create my users. Also I want to store additional information about the users. So I tried following the instructions given at
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
but I cannot get it to work for me. Is there a step-by-s...