django

Django add / remove form without multiple submit

I want a simple edit / remove form in Django. I want it to look like: Item A edit / remove Item B edit / remove Item C edit / remove I want to the edit and remove "buttons" to be hyperlinks, or at least look like them. Is there an easy way without multiple submit buttons (and without violating the whole POST/GET thing...

Django ImageField Override the File Collision Code

Hi, I would like to have 2 ImageFields in a Model. being the one where the user uploads an image being one where we have a copy of that image, but using the Same File. Note: I am simplfying the reason for the two fields. Apart from Creating a new ImageField field type is there any way to stop the ImageField adding a _ to the filena...

Easiest way to remove leading zeroes from Django TimeInput form widgets?

I'm building an Django app that requires users to enter the time of day in TimeFields and I'm trying to format this as nicely as possible. My code currently looks like this: start = forms.TimeField(widget=forms.TimeInput(format="%I:%M %p")) end = forms.TimeField(widget=forms.TimeInput(format="%I:%M %p")) Where the values in the format...

Django, sorl-thumb dont work

Hi guys, i dont know what im doing wrong, but sorl-thumb just upload the image but dont make thumbs... model.py from sorl.thumbnail.fields import ImageWithThumbnailsField ,ThumbnailField imagen = ImageWithThumbnailsField(upload_to='images', thumbnail={'size': (75, 75)}, ...

Can I tell if a view is being called by the django TestClient

I'm implementing a custom log-in screen for a django site I am working on and users will be presented with a CAPTCHA challenge every time they log on. (Sounds like overkill I know but for a whole bunch of complex reasons it is impossible to set a decent password policy which leaves the log in open to brute force attacks) I want to be ab...

Elegantly handle site-specific settings/configuration in svn/hg/git/etc ?

I've been looking for a better way to deal with site-specific settings (in this case, the django settings.py file). The settings.py structure and fields are fairly consistent, but the values differ between the developer's boxes, the integration, QA, testing, and production environments. What's an elegant way to have the settings sourc...

Django Admin: Making mandatory fields non-mandatory dynamically

How can I make mandatory fields non-mandatory when another [associated] field has a certain value? Let's assume I have the following models: class foo(models.Model): bar = models.CharField(max_length=200) foo_date = models.DateTimeField() When I save, and bar contains a certain value, i'd like foo_date to become non-mandatory...

Narrowing choices in Django form

I have a model like: CAMPAIGN_TYPES = ( ('email','Email'), ('display','Display'), ('search','Search'), ) class Campaign(models.Model): name = models.CharField(max_length=255) type = models.CharField(max_length=30,choices=CAMPAIGN_TYPES,default='display') ...

Apache Django Ajax time or size limit

My ajax responses seem to die out now that I am sending so much data in response to a search form request. I'm using Django with Apache and Firefox and Chrome noth die out if I don't limit my search to few enough results. What's the time or size limit to an Ajax response? ...

What's the equivalent of Rails' Migrations or Django's South in Pylons and TG2?

Does anyone know how Pylons and TG2 projects handle database migrations? I'm looking for something similar to Rails' Migrations and Django's South. ...

django templates: include and extends

I would like to provide the same content inside 2 different base files. So I'm trying to do this: page1.html: {% extends "base1.html" %} {% include "commondata.html" %} page2.html: {% extends "base2.html" %} {% include "commondata.html" %} The problem is that I can't seem to use both extends and include. Is there some way to d...

How do I hide the field label for a HiddenInput widget in Django Admin?

I've got a bit of Django form code that looks like this: class GalleryAdminForm(forms.ModelForm): auto_id=False order = forms.CharField(widget=forms.HiddenInput()) And that makes the form field go away, but it leaves the label "Order" in the Django admin page. If I use: order = forms.CharField(widget=forms.HiddenInput(), labe...

Django generic view, and " most view " article

Hi guys, im using generic view, i would like to update a field (most_view) in another database table. How ill update or create a new register for "most view" when the user are reading a article? ulrs.py from Paso_a_Paso.noticias.models import Noticia noticias_info_dict = { 'queryset':Noticia.objects.all(), 'date_field...

Auto-generate form fields for a Form in django

I have some models and I want to generate a multi-selection form from this data. So the form would contain an entry for each category and the choices would be the skills in that category. models.py class SkillCategory(models.Model): name = models.CharField(max_length=50) class Skill(models.Model): name = models.CharField(max_l...

Rounding off decimals in Django

I want to round off my decimal values as below: 7,715.625 becomes 7,716 How do I achieve this? ...

How do I build a queryset in django retrieving threads in wich a user has posted?

I'm making a threaded forum app using django-mptt. Everything is up and running, but I have trouble building one specific queryset. I want to retrieve posts which: 1) are root nodes 2) are posted by current_user or have a descendant posted by current_user. What I have so far is this: Post.objects.filter(Q(user = current_user) | Q...

How to set a Flatpage as the Homepage in Django

How can I set a Flatpage as the Homepage? My urls.py is (r'', include('django.contrib.flatpages.urls')), In the admin section I set the URL of the Flatpage to "/". I get this error Firefox has detected that the server is redirecting the request for this address in a way that will never complete. I'm guessing setting ...

How do I stop getting ImportError: Could not import settings 'mofin.settings' when using django with wsgi?

I can't get wsgi to import my settings file for my project 'mofin'. The list of errors from the apache error log are as follows mod_wsgi (pid=4001): Exception occurred within WSGI script '/var/www/wsgi-scripts/django.wsgi'. Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 2...

What is the best way to set far future expires on images with Django?

I am using django-compress with far future expires for my css and js files. Works great. I'd like to do something similar for other static content (images, flash, etc). I can set a far future expires on this content, but I must manually rename the files when they change. Is there a better way to handle this? ...

Django: Skipping model validation

Hi I'm using the development server (runserver) in Django and it's started to annoy me that Django is validating the models every time I save a file and the server restarts. I have ~8000 entries in my SQLite3 database and it takes up to five seconds to validate the models. I'm not familiar with how Django validates the models, but I'm...