django

Parent/Child(ren) Hierarchy / "Nested Sets", in Python/Django

I'm using Django/Python, but pseudo-code is definitely acceptable here. Working with some models that already exist, I have Employees that each have a Supervisor, which is essentially a Foreign Key type relationship to another Employee. Where the Employee/Supervisor hierarchy is something like this: Any given Employee has ONE Super...

Can a django model have two abstract classes?

I have this models: class BillHeader(models.Model): billno = models.IntegerField(primary_key=True, blank=True) class BillData(models.Model): price = models.DecimalField(_('Price'), max_digits=12, decimal_places=2) amount = models.DecimalField(_('Amount'), max_digits=6, decimal_places=2) [... rest of the model ...] ...

Executing a python script using subprocess.Popen() in a django view

I've looked around a bit but I can't seem to solve this problem I have. I'd like to execute a python script within a view of my django app. I've placed the code I'd like to execute inside a django management command so it can be accessed via command line python manage.py command-name. I then tried to run this command using subprocess....

How to make Django url dispatcher use subdomain?

I have a vague idea on how to solve this, but really need a push :) I have a Django app running with apache (mod_wsgi). Today urls look like this: http://site.com/category/A/product/B/ What I would like to do is this: http://A.site.com/product/B This means that the url dispatcher some how needs to pick up the value found in the subdo...

How can I group objects by their date in Django?

I'm trying to select all objects in the articles table, and have them grouped by their date. I'm thinking it would look similar to this: articles = Article.objects.filter(pub_date__lte=datetime.date.today()).group_by(pub_date.day) articles = {'2010-01-01': (articleA, articleB, articleC...), '2010-01-02': (article1, article2,...

Which openid / oauth library to connect a django project to Google Apps Accounts?

I'm working on an intranet django project (not using GAE) for a company that uses Google Apps for login. So I'd like my users to be able to log in to my django project using their google accounts login. OpenID seems appropriate, although maybe Oauth might work too? I see a lot of similarly named libraries out there to connect django's...

Which is faster to learn: Django (Python) or Ruby on Rails (Ruby)?

I have done the front-end of my design, but I have no experience in web programming. Would like to pick up a language asap so that I can deploy the product. Which is faster to pick up between the two? I know there is always debate in which is better. I think either one serves well for me, but I want to know which one is easier to learn, ...

Can't get Django format localization working

I am trying out Django 1.2's spiffy new localization feature. settings.py USE_L10N = True LANGUAGE_CODE = 'sv-SE' sometemplate.html {{32.519823}} Is rendered as: 32.519823 In Sweden, the decimal separator should be (, comma) not (. period). Am I missing something? ...

Django & Postgis : Distance lookup using ST_Distance_sphere

In Django documentation, I read this (http://docs.djangoproject.com/en/dev/ref/contrib/gis/geoquerysets/#id7): On every distance lookup but dwithin, an optional third element, 'spheroid', may be included to tell GeoDjango to use the more accurate spheroid distance calculation functions on fields with a geodetic coordinate system (e.g...

Django - managing multiple pages with multiple fields

Hi! I am using Django for developing a website and I want to allow my staff to be able to add/edit/delete pages with multiple text fields. I am planning to use Django's admin framework for this as the staff is a non-technical one.But I have no clue on how to go about doing this so that people can login and edit the contents on these ...

approaching django model fields through a field name mapping

Hi Guys, Django newbie here, I have several types of models, in each of them the fields have different names (e.g. first_name, forename, prenom) and I want each of the models to contain a mapping so that I can easily approach each of the fields using one conventional name (e.g. first_name for all of the field names). what's a good way o...

modify admin auth backend

hello! By default, after authentication on /admin, function authenticate() returns User object, what if i want to get proxy model for the User (i.g. called HandyUser) in return ? In my project, in all custom auth backends, i'm using HandyUser instead of User. thanks ...

How can i kick off a user who has logged-in in django?

I am using Django. How can i kick off a user who has logged-in? or How can i get the user's session and kill it? ...

Get Model Field Name in Template

In a template for a view I would like to use the name of a field and not just the value. So for example if I have this: class Test(models.Model): name = models.CharField(max_length=2, verbose_name = 'Your name') age = models.PositiveSmallIntegerField(max_length=3) I would like to be able to do {{ name.get_field_name_display }} which...

Flex and Django for web application - Does it work well together?

Hi, I'm building from scratch a web application that is not trivial (have some algorithms and calculations in the backend) but not too complex (it doesn't have to process lots of records during runtime.) We thought about using Django for the backend in order to be able to develop the application fast with flex based GUI. I'm a Java dev...

Manipulating the db with SQL Server 2005 - Django

Hi folks, I'm trying to accomplish the following: Grab the db schema Grab any constraints* Alter tables Add/Drop tables I'm currently using pyodbc backend for Django. I would like to perform all these tasks within a view file. I'm using the following in order to grab fields of tables starting with 'core_': SELECT table_name,or...

django uml database

hello, Is there any possibility to export the Django database into some kind of a UML tool, so that i can see graphically see the relations between tables (or even between classes) ? thanks! ...

Showing partial tabular inline models in Django

Let's see if I can explain myself, I have this models: class BillHeader(models.Model): number = models.CharField(_('Bill number'), max_length=10, unique=True, \ default=__number) client = models.ForeignKey(ClienteYProveedor, verbose_name=_('Client')) date = models.DateTimeField(_('Date'), default=datetime.now) def _...

django calendar widget

I want to have a calendar in my application, so that every user can pick a date, and submit a meeting poll. I tried using the Django calendar admin widget, but it doesn't appear on my page. How can i get a calendar for my app? it is easier to use a java script one? Thanks! ...

django, multiple databases, configuration issue: "Error importing database router"

Hi there, I've followed these instructions to set up Django with multiple databases. It's working as intended in my local dev environment (win7), however, when I upload the project to my live server (webfaction), I get ImproperlyConfigured: Error importing database router MyCustomRouter: "No module named path.to.my.router" From the Dj...