django

Why doesn't gettext have a db storage option?

Hi all, I'm doing some i18n on a web-based app using Django, which uses gettext as its i18n foundation. It seems like an obvious idea that translations should be stored in the database, and not difficult to do, but po files on the filesystem are still being used. Why is this? My current suspicion is that the benefits of developing a d...

Managing a Django application/project as it grows ( in terms of changes in models, increase in features )

Hi all, I need your advice on managing a Django application as it grows in terms of features and models. For instance as a application grows, we often need to add in new features. Adding new features involves adding new models, or adding a new field within a model. How would you go about doing that without closing the web application...

Lingering Django Database

I had to remove my Django Database (drop all the tables). Now when I try to run "manage.py syncdb" to recreate those tables I get the message "Table 'user_database.engine.city' doesn't exist" Is there a file lingering that is telling djnago these tables still exist? EDITED QUESTION: I had to remove my Django Database (drop all the tab...

Create directory while upload using django

After uploading a file from the UI, how to create the a new directory with the current timestamp in /opt/files/ and copy the uploaded zip file to this directory, and unzip the zip file in the new directory and maintain the new directory name in a variable def upload_info(request): if request.method == 'POST': fi...

Django model inheritance and type check

class Machine(models.Model): name= models.CharField( max_length=120) class Meta: abstract = True class Car(Machine): speed = models.IntegerField() class Computer(Machine) ram = models.IntegerField() My question is, how can I understand what type is the Machine model. For instamce I know the incoming query is a...

Is there a better error reporting via e-mail for Django?

Quite often the error reports coming via e-mail are less than useful in tracking bugs. Most often this is due to missing session data and username of the user triggering the error. Is there a project or a library I could use to get more complete error reports? ...

filter on a many_to_many field

Hi, new to django, this might be a simple/obvious question, so I apologise in advance. I have the following model class Team(models.Model): name = models.CharField(max_length=100) members = models.ManyToManyField(User, related_name="members", blank=True, null=True) And the following view (controller) def my_teams(request): ...

Is there any way to reuse template tag value in Django templates?

For example, let's say there is a custom template tag {% custom_tag "parameter" %} This tag requires some serious database work to calculate. Now I need to have something like that (pseudocode): if {% custom_tag "parameter" %} .... else .... I know that with context variables I can do just: {% with variable.x.y.z as v %} {% i...

Membership and event API? Or should I do it myself?

I've been tasked with setting up a society's website. I'm a full time Django (at al) web developer so I was happy to take on the task. Going through the specs, they want to control memberships so that all applications need a "second" (read: sponsor, referee, etc) and then they need to pay a subscription fee to be part of the club. Thi...

How to cater for 'AnonymousUser' when filtering based on user

I have the following model class Team(models.Model): name = models.CharField(max_length=100) members = models.ManyToManyField(User, related_name="members", blank=True, null=True) And the following view (controller) def my_teams(request): my_list = Team.objects.filter(members=request.user).order_by('name') return rende...

Django Model copy with ManyToManyField

Trying to copy a Django model with ManyToManyField. the model is class Book(models.Model): cats = models.ManyToManyField(Category) the view: for book in books: book.name = "New Name" messageinfo = message.save() msg = Book(title=book.title, subject=book.subject) msg.save() sort of works till here, makes a co...

The "next" parameter, redirect, django.contrib.auth.login

I'm trying to redirect users to custom url "/gallery/(username)/" after successfully logging in. It currently redirects to the default "/account/profile/" While I know what I can override the redirect url in my settings.py, my url is dynamic thus it will not work. Documentation states that I need to use the "next" parameter and contex...

Sending emails when a user is activated in the Django admin

I'm about to create a site that has monitored registration in that only certain people are allowed to register. Undoubtedly some misfits will register despite any writing I put above the registration form so we're going with moderation. Upon registration a django.contrib.auth User and profile will be created and an email will be sent to...

Django Admin: how to display properties defined on model in an inline?

This is a follow-up to this question. How do I display properties defined on a child model in an inline on the parent? To illustrate, I have this model: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, primary_key=True, related_name='profile') ... @property def age(self): if self.birth...

Calendar input like admin application Django

Hi, Using the django admin application for a date it displays Today | CalendarSymbol. I am using a datefield in my form and I thought it would do this for me how would i go about doing this? As i would normally use the jquery datepicker plugin is this the way to go? Thanks in Advance, Dean ...

How to catch an OperationFailure from MongoDB and PyMongo in Python.

I have been having a problem where after my mongodb connection to mongohq via pymongo goes idle for awhile (no queries), it will timeout. This is fine, but the connection the database is only created when the Django app is started up. It seems like it is reconnecting fine, but it needs to reauthenticate then. When the connection has died...

django cleaned_data [help]

ok so I have the following problem i`ve looked around but I cant find a solution ... lets say I have the following forms.py from django import forms class LoginForm(forms.Form): _username = forms.CharField() _password = forms.CharField() and in views.py I have def index(request): if request.method == 'POST': fo...

Serving secure Django pages with HTTPS

What is the proper deployment configuration for a Django application that needs some pages served with HTTPS and others with HTTP? I want to use HTTPS for the pages that involve registration and inputting passwords. I want to use HTTP for all other pages. ...

Change font/color for a field in django admin interface if expression is True

Hi folks, is it possible to mark some fields/rows red in django admin interface if they achieve a expression? For example, if there is a model "Group" with members and capacity, how can I visualize when they are full or crowded? ...

Running a python script for django via cron

I have a python script that connects to an external host, fetches some data, and populates a Django database with the data. The python script that populates the database uses these lines to setup the django environment: path = os.path.normpath(os.path.join(os.getcwd(), '..')) sys.path.append(path) from django.core.management import setu...