django-models

How to add CometChat in my Django project ?

Is there a way to add this chat in my django project? : http://www.cometchat.com/ ...

django inheritance with foreignkey field

My models are set up as follows (this is an example and not my actual models) class modelA(Model): field1 = CharField(max_length=50) class modelB(modelA): field2 = CharField(max_length=50) class anotherModel(Model): connection = models.ForeignKey(modelA) title = CharField(max_length=50) Would I be able to have an connect...

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...

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? ...

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...

django-admin formfield_for_* change default value per/depending on instance

Hi, I'm trying to change the default value of a foreignkey-formfield to set a Value of an other model depending on the logged in user. But I'm racking my brain on it... This: Changing ForeignKey’s defaults in admin site would an option to change the empty_label, but I need the default_value. #Now I tried the following without errors b...

Django: Is there any way to have "unique for date range"?

If my model for Items is: class Item(models.Model): name = models.CharField(max_length=500) startDate = models.DateField("Start Date", unique="true") endDate = models.DateField("End Date") Each Item needs to have a unique date range. for example, if i create an Item that has a date range of June 1st to June 8th, how ...

Ditching Django's models for Ajax/Web Services

Recently I came across a problem at work that made me rethink Django's models. The app I am developing resides on a Linux server. Its a simple model/view/controller app that involves user interaction and updating data in the database. The problem is that this data resides in a MS SQL database on a Windows machine. So in order to use ...

Matching 3 out 5 fields - Django

Hi folks, I'm finding this a bit tricky! Maybe someone can help me on this one I have the following model: class Unicorn(models.Model): horn_length = models.IntegerField() skin_color = models.CharField() average_speed = models.IntegerField() magical = models.BooleanField() affinity = models.CharField() I would like to sea...

Django - categories & sub-categories

Some advice needed on how I can structure my models for my site. I have seen this post from Django project but still a little lost. Also come across Django-MPTT - but that's no help and possibly overkill. I'm looking to have categories & subcategories that are shown in the URLs like this: mysite.com/Level1/Maths/Calculations/Addition/...

Is there an OR filter? - Django

Hi folks, is there any way of doing the following Unicorn.objects.or_filter(magical=True).or_filter(unicorn_length=15).or_filter(skin_color='White').or_filter(skin_color='Blue') where or_filter stands for an isolated match I remember using something similar but cannot find the function anymore! Help would be great! Thanks :) ...

Django: Inherit Permssions from abstract models?

Is it possible to inherit permissions from an abstract model in Django? I can not really find anything about that. For me this doesn't work! class PublishBase(models.Model): class Meta: abstract = True get_latest_by = 'created' permissions = (('change_foreign_items', "Can change other...

Django multilanguage support

Using django if a text is stored in French or Hindi.How will this be stored and retrieved in a text box field Models.py class Details(models.Model): title = models.CharField(max_length = 255) html page: <form action="/pjt/details"> <input type="text" name="nee_n"id="neen_n" /> </form> How to store this in the ...

Using Django's memcache API on Dynamically created models.

So I have a function which creates a dynamic model. I accomplish this in a way very similar to AuditTrail (see django wiki). Sample of code is here: https://gist.github.com/0212845ae00891efe555 Is there any way I can make a dynamically-generated class pickle-able? Ideally something thats not a crazy monkeypatch/hack? ...

Django: Validation error in Admin

NEWBIE ALERT! background: For the first time, I am writing a model that needs to be validated. I cannot have two Items that have overlapping "date ranges". I have everything working, except when I raise forms.ValidationError, I get the yellow screen of death (debug=true) or a 500 page (debug=false). My question: How can I have an er...

Does Django Have a Way to Auto-Sort Model Fields?

So basically, I've got a rather large Django project going. It's a private web portal that allows users to manage various phone-related tasks. Several pages of the portal provide a listing of Model objects to users, and list all of their attributes in a HTML table (so that users can visually look through a list of these items). The pro...

ActiveRecord without setting up database tables? (declarative like Django)

In Django, you fully describe your models in models.py. In Rails with ActiveRecord, you describe part of a model in in the /models directory, and part of it in migrations. Then ActiveRecord introspects model properties from the existing database tables. But I find migrations, columns, and tables to be a headache. How can I do like ...

How to disable Middleware and Request Context in some views.

I am creating a chat like facebook chat... so in views.py of my Chat Application, I need to retrieve only the last messages every 3-4 seconds with ajax poll ( the latency is not a problem for me ). If I can disable some Middlewares and some Request Context in this view, the response will be faster... no ? My question is: Is there a w...

user model password field default password field in django

Hi, I've created a custom user model in my application. This user model is working fine, but there are a couple of problems I have with it. 1) The change password link in the my register.html page doesn't work? 2) The default password box on the add/edit page for a user is a little unfriendly. Ideally, what I'd like is the two password f...

** UPDATED ** 'NoneType' object has no attribute 'day'

Hi guy, i dont know where is my error, but Django 1.2.1 is give this error: 'NoneType' object has no attribute 'day' when i try to save form from the Administrator Area models.py from django.db import models from django.contrib.auth.models import User class Editorial(models.Model): titulo = models.CharField(max_length=250,help_t...