django

Unable to override SelectMultiple widget in ModelForm (Django)

I have a ManyToManyField that I want to present in a form, as a CheckboxSelectMultiple widget. Why don't any of these methods work? (See Attempt #1, #2 and #3 below.) According to everything I've read in the docs and on SO, at least one of them should work. But I still have a stubborn SelectMultiple widget that refuses to budge. from d...

django: where should I put upload directory

What is the preferred place to keep upload directory for a django project? I am pretty sure I shouldn't keep it inside the project for production, because then I have to always remember to move it between projects, if I upload a new version of my project. Where should I keep it then? (I am talking about a linux machine). ...

django admin: customize delete user functionality

Hi All, I am working on a Django application on Google app engine (using app engine patch). In my project I have to customize the way the delete functionality works in the admin panel. I have defined my own functions for all the models that I have created and its working fine. Now the issue is to customize the delete functionality for...

Django Login App Tutorial problems

I am having problems running through a tutorial and it seems the problems stem from this: (r'^l/login/$', 'django.contrib.auth.views.login'), It seems I have done all correct, but the forms dont show. If I hit Login. I get back to the same page without forms. Did I miss something? Here the code: urls.py: from django.conf.urls.def...

Django: Accessing method on child different child classes through common name

I have an abstract base class for defining common attributes shared by different user profiles. class Profile(models.Model): ... def has_permissions(self, project): ... class Meta: abstract = True class Standard(Profile): ... class Premium(Profile): ... Now I would like to check the permission of a certa...

paginator django tutorial ?

I am trying to implement a simple paginator example. Is there any tutorial, example that runs through one SIMPLE example from start to finish. urls.py views.py settings.py models.py I am aware of this one: http://docs.djangoproject.com/en/1.1/topics/pagination/ But this assumes you already have urls, models and settings. Thanks. ...

Is there a way to make block optional in Django

In Django's templates system, if I have a block that I want to make optional using an if statement, how do I do it? I was trying this: {% if val %}{% block title %}Archive {{ foo }}{% endblock %}{% endif %} But that doesn't work. Is there a way to do that, so that for a given value (in this case Null) the block isn't issued and the ...

Pagination Django One Image

I would like to have a "pagination" where I would have one image per page. My current code is pasted below. Unfortunatley now I get ALL images on EVERY pagination. Which is already a step in the right direction but not quite what I want. How can I just have one image per page e.g Images 1 of my os.listdir and below that a link to the ne...

Django: Is there a way to set global views? For example enable data for a sidebar through all URLS

Hello I am building a Django application that is a pretty basic blog, so far it has been wonderful. I got comments, tags etc up. But one thing is bugging me: I cant get the sidebar i want to work. I use the django.views.generic.date_based generic view and this is my urls.py for the blog: urlpatterns = patterns('django.views.generi...

How to lock django command for single run. Django. Python.

How to lock django commands so it will not run twise in the same time? ...

Auto-truncating fields at max_length in Django CharFields

I have a field that has a max_length set. When I save a model instance, and the field's value is greater than max_length, Django enforces that max_length at the database level. (See Django docs on models: http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.CharField.max_length) However, since I am using Postgres, I ...

a fairly complex django query

I've got class Supplier(Model) : pass class Customer(Model) : pass class Dock(Model) : pass class SupplierDockAccess(Model) : supplier = ForeignKey(Supplier) dock = ForeignKey(Dock) class SupplierCustomerAccess(Model): supplier = ForeignKey(Supplier) customer = ForeignKey(Customer) I have an instance of C...

Django/Python resize image

Hello. I have a image from files = request.FILES['new_photo'].read() and i want to know it's size and possibly resize it. How i can do it? thanks. UPD before. i read() file and gave this string and some info? to SQL function. And she save it on ftp. how i can get data same as the data returned from read() method? i try to use ...

Django Url Not Resolving with Query Parameters

I have an issue where I need to pass in query parameters for a GET request, but Django is not resolving the URL correctly to the view. My urls.py looks like this: from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^confirm_cancel', 'myapp.views.confirm_cancel_method', name='myapp...

Format date like: Monday, 1st March

Seems like it should be simple enough but it's driving me up the wall. I've looked at the python date formatting strings and it still doesn't make too much sense. Here's what I'm trying to do: <Full day>, <Day of month><Ordinal> <Month> Where <Ordinal> is st, nd, rd, th, etc depending on the day. ...

Serving favicon.ico with Django. Why does settings.MEDIA_URL with django.views.generic.simple.redirect_to only work on dev environment?

Hi guys! I found this solution for serving favicon.ico with django. (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': settings.MEDIA_URL+'images/favicon.ico'}), I do not understand why it only works for the development server. Going to /favicon.ico works on dev, doesn't with debug=False It should redirect to /med...

Django: Applying permissions in the URL dispatcher?

In my Django application, I have certain permissions which users need in order to access certain views (using django.contrib.auth). This works fine, using the @permission_required decorator on my view functions. However, some of my URLs resolve to views which I did not write, such as the built-in django.contrib.auth.views.password_chan...

Django, subdomains and mod_rewrite. URLs messing up on deployment setups.

I have a Django application being served of (say) example.com. It contains a number of sub-applications (say) strength, speed and skill. The URL scheme is something like http://example.com/strength, http://example.com/speed and http://example.com/skill. This is how I run my dev server (using runserver) and there are no problems whatsoeve...

Django virtualenv deployment configuration

I recently start to use virtualenvwrapper and created mkdir ~/.virtualenvs mkvirtualenv example.com Virtualenvwarpper automatical create a virtualenv named example.com under ~/.virtualenv so this is the central container for all virtualenvs. After than I installed django and some other packages via pip and my site is at /srv/www/ex...

Is there way to make costum signal when Manytomany relations created? Django!

Is there way to make custom signal when ManyToMany relations created? ...