django

In Django, what is the right place to plug in changes to the user instance during the login process?

Background I have a custom authentication back end for our django applications that refers to an LDAP server. As soon as I authenticate someone, I have a wealth of information that our network infrastructure guys put in the LDAP server about the user - their last names (which can change, for instance, if they marry), their e-mails (whi...

Searching and Count records matching criteria in Django

I'd like to have a sorted list of certain database fields in my app e.g say year (where I'll have all records having a certain year tallied and the total displayed as in: 2009 (10), 2008(3) etc) then clicking on a certain year will display these records. How should I do this? EDIT 1 class Year(models.Model): year = models.PositiveSm...

how can I limit to display a message only upon the login

I would like to learn how to limit a particular part of a template to be displayed upon the user login. E.g. the greeting message in the home page will be displayed once after the user's successful login but not again on the consecutive visit of the home page during the same session. I guess it could be possible by use of the HTTP_referr...

how to change default dateformat AAAA-MM-DD to dd/mm/yyyy in Django?

My locale dateformat is dd/mm/yyyy and Django is requering AAAA-MM-DD when the user inputs 04/11/2009 Django raises: _('Enter a valid date in YYYY-MM-DD format.')) Im using simple html input field type="text", Not forms.DateField Thanks :) ...

Trying to display a list with no primary key. (i dont even know if this is the right title)

I have a model with no primary key. it has the id's from other models. I want to call iid_ id. For example iid_id = 1. There are 21 rows with the number 1. I want to grab all the rows and display them on a HTML table. The Model: class QryDescChar(models.Model): iid_id = models.IntegerField() cid_id = models.IntegerField() ...

testing for a blank file upload

I have a model that looks like this: class ProjectImage(models.Model): project = models.ForeignKey(Project) in_slideshow = models.BooleanField(default=False) large_thumb = ImageWithThumbnailsField( upload_to='projects', thumbnail={'size': (500, 384), 'options': ['crop']}, generate_on_save=True, )...

Adding more CoC to Django

I come from a Cake background, and I'm just starting to learn Django now. I'm liking it quite a bit, but I kinda wish it used convention over configuration like cake does. So, How can I get Cake-style URLs automatically? For example, if I went to mysite.com/posts/view/5 it would load up mysite.posts.views.view and pass an argument 5 to...

accessing memcached stats via cmemcache or django returns warning

Hi, My Django application uses memcached via cmemcache. An issue sprung up when I was trying to monitor its usage: I tried to access stats memcached provides through both Django and cmemcache: django: from django.core.cache import cache cache._cache.get_stats() [[email protected]] mcm_server_stats():3027: unknown stat variable: ...

in Django admin how can I know a boolean is set true for the first time only

I have a model that contains a boolean field representing the item's approval or not. I'd like to send an email when the box is checked. I understand how to override the save method and send the email if it's true but this will send an email every time it's saved. As I only want to send the email once, is there a way to check a boolean...

Django very tiny modification - logical delete

Hi, I want to make the following tiny modification to the Django framework. I want it to create a "deleted" field for each model I create, plus of course I want it to be checked as deleted when I delete it from the admin page instead of being physically deleted, and I dont want these records checked as deleted to be listed. I'm new to ...

Django limit_choices_to at circular relation

Hi, I've implemented a circular OneToMany relationship at a Django model and tried to use the limit_choices_to option at this very same class. I can syncdb without any error or warning but the limit is not being respected. Using shell I'm able to save and at admin I receive the error message: "Join on field 'type' not permitted. ...

Do we need cache for an array?

Hi All: Since we're developing a web-based project using django. we cache the db operation to make a better performance. But I'm wondering whether we need cache the array. the code sample like this: ABigArray = { "1" : { "name" : "xx", "gender" "xxx", ... }, "2" : { ... }, ... } class Items: de...

I can't view pages in admin of django-cms

I install django-cms. I try to use the example spplied by the installation package. I have some questions : I can add pages to my site. but when I try to list all my pages in the tree-view (using the "Select page to change" view) . The tree view is blank? Does anyone had the same problem? ...

Django Formsets - form.is_valid() is False preventing formset validation

I'm am utilizing a formset to enable users subscribe to multiple feeds. I require a) Users chose a subscription by selecting a boolean field, and are also required to tag the subscription and b) a user must subscribe to an specified number of subscriptions. Currently the below code is capable of a) ensuring the users tags a subscription...

Django treebeard what are differences between AL, NS, MP

Hi! I'm trying to make a model for categorizing some objects. I already tried using django-mptt to easily retrieve related categories, and now I'm searching different solutions to find the best one. I can't find out though what are main differences between Materialized Path, Adjacency List and Nested Set. Wikipedia didn't give me a sh...

Permission Denied error with Django while uploading a file

Hi guys, I currently have a simple model defined, with a photoupload feature using django thumbnails plugin. but when i try to upload it gives me the following error: OSError at /admin/products/photo/add/ (13, 'Permission denied') Now, i know this is seems to be a permission issue, so the first thing i checked were permissions on ...

Django: Blank Choices in Many To Many Fields

When making forms in Django, the IntegerField comes with a blank choice (a bunch of dashes "------") if called with blank=True and null=True. Is there any way to get ManyToManyField to include such an explicit blank choice? I've tried subclassing ManyToManyField with no success: class ManyFieldWithBlank(ManyToManyField): """ ...

Sending SMTP email via Django in production environment

Hello, I am using Django-Registration for my website on a linode ubuntu virtual. I get connection problem sending activation email when users sign up. Here is my settings: EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = '[email protected]' EMAIL_HOST_PASSWORD = 'mypassword' EMAIL_USE_TLS = True I've tested local...

Django: Streaming dynamically generated XML output through an HttpResponse

Dear fellow users, recently I wanted to return through a Django view a dynamically generated XML tree. The module I use for XML manipulation is the usual cElementTree. I think I tackled what I wanted by doing the following: def view1(request): resp = HttpResponse(g()) return resp def g(): root = Element("ist") list...

'getattr(): attribute name must be string' error in admin panel for a model with an ImageField

I have the following model set up: class UserProfile(models.Model): "Additional attributes for users." url = models.URLField() location = models.CharField(max_length=100) user = models.ForeignKey(User, unique=True) avatar = models.ImageField(upload_to='/home/something/www/avatars', height_field=80, width_field=80) ...