django

User-based model instances filtering in django admin

I'm using django's admin to let users manage model instances of a specific model. Each user should be able to manage only his model instances. (except for administrators which should manage all). How do I filter the objects in the admin's changelist view? Thoughts: I guess the most elegant approach would be to use Object-level permis...

inheritance from the django user model results in error when changing password

I inherited form the django user model like so: from django.db import models from django.contrib.auth.models import User, UserManager from django.utils.translation import ugettext_lazy as _ class NewUserModel(User): custom_field_1 = models.CharField(_('custom field 1'), max_length=250, null=True, blank=True) custom_field_2 = mo...

Problems trying to format currency with Python (Django)

I have the following code in Django: import locale locale.setlocale( locale.LC_ALL, '' ) def format_currency(i): return locale.currency(float(i), grouping=True) It work on some computers in dev mode, but as soon as I try to deploy it on production I get this error: Exception Type: TemplateSyntaxError Exception Value: Caught Val...

Render multiple Form instances

I have a simple application where users are supposed to bet on outcome of a match. A match consists of two teams, a result and a stake. Matches with teams are created in the Django admin, and participants are to fill in result and stake. The form must be generated dynamically, based on the matches in the database. My idea is to have on...

Aptana Studio is opening but not ever closing a python.exe process

I am developing a small testing website using Django 1.2 in Aptana Studio build 2.0.4.1268158907. I have a Django project that I test by running the command "runserver 8001" on my project. This command runs the project on a small server that comes with Django. However the problem arises that every time I run this command Aptana opens ...

Django call function when an object gets added

Hay, i have a simple model class Manufacturer(models.Model): name = models.CharField() car_count = models.IntegerField() class Car(models.Model): maker = ForeignKey(Manufacturer) I want to update the car_count field when a car is added to a manufacturer, I'm aware i could just count the Manufacturer.car_set() to get the v...

Django or Drupal, which one should I use that suits best my needs ?

Hello, I want to learn and use Drupal or Django for the following: dynamic web sites, medium database, multi-level users, paypal integration, content managment, speed (developing), security I like MVC, ORM and object-oriented prg. Which is better to jump into ? Which one is more mature, powerful, understandable, object-oriented an...

django-lfs with multilanguage

After I complete integrating lfs with my django-app , I just curius that lfs has a module or support about this issue ...

django: check for modeladmin for a given model

How does one check to see if a modeladmin exists for a given model? modeladmins are created by registering a model with the admin.site object. how can one check the site object to see which models have been registered, and with which admin_class? ...

Cannot save property group to product in django-lfs

I already create properties and add them to property group.Then I assign to my new product.But django show me TypeError at /manage/update-product-properties/1 save() got an unexpected keyword argument 'using' ...

get request.session from a model method in django

Hay, is it possible to a get a request.session value from a model method in django? MEGA UPDATE Here is my model class GameDiscussion(models.Model): game = models.ForeignKey(Game) message = models.TextField() reply_to = models.ForeignKey('self', related_name='replies', null=True, blank=True) created_on = models.DateTim...

Best, free, online Python tutorials and references for an experienced programmer?

I have been doing Java, and C# for many years. Starting on my first big Python program now. I have written a few, very small, text processing scripts in Python years ago. I would like to know what is the best, free, online Python tutorial for experienced programmers. Python in general, but then also web programming with Python. Will be ...

Crossed import in django

On example, i have 2 apps: alpha and beta in alpha/models.py import of model from beta.models and in beta/models.py import of model from alpha.models manage.py validate says that ImportError: cannot import name ModelName how to solve this problem? ...

django filter icontains match whole words only

Hi, I am using the filter icontains to search for words but I only want it to match whole words. e.g. if I searched for liver I wouldn't want it returning delivery. my query looks like this MyModel.objects.filter(title__icontains=search_word) I have seen the filter __search but this does not bring back results with 3 characters or l...

Login URL using authentication information in Django

I'm working on a platform for online labs registration for my university. Login View [project views.py] from django.http import HttpResponse, HttpResponseRedirect, Http404 from django.shortcuts import render_to_response from django.template import RequestContext from django.contrib import auth def index(request): return render_to...

Django forms: how to dynamically create ModelChoiceField labels

I would like to create dynamic labels for a forms.ModelChoiceField and I'm wondering how to do that. I have the following form class: class ProfileForm(forms.ModelForm): def __init__(self, data=None, ..., language_code='en', family_name_label='Family name', horoscope_label='Horoscope type', *args, **kwargs): super(ProfileFo...

Managers, model inheritance or what for slicing Users in django?

Hi guys, I'm writing a Project in Django where I've 5 kind of groups of Users: Group1 Group2 ... Then I've a Model, Item which has many relation with users, the Item has one Owner (a User in Group1), a Customer (an User in Group2) and many RelatedUser (Users in Group3). I'm wondering which is the correct way to write this relations...

A Locale in a Django application not showing

I want to localize a Django project on application basis, ie. have separate localization for each app, not the entire project. Here's what I did: cd <project root> mkdir locale django-admin makemessages -l ru (translated some strings) django-admin compilemessages (added the language to settings.py, restarted the server) USE_I18N ...

Best practice: How to persist simple data without a database in django?

I'm building a website that doesn't require a database because a REST API "is the database". (Except you don't want to be putting site-specific things in there, since the API is used by mostly mobile clients) However there's a few things that normally would be put in a database, for example the "jobs" page. You have master list view, an...

Best way to optimize queries like this in Django

I am trying to lower the amount of queries that my django app is using, but I am a little confused on how to do it. I would like to get a query set with one hit to the database and then filter items from that set. I have tried a couple of things, but I always get queries for each set. let's say I want to get all names from my DB, b...