django

How to save a model without sending a signal?

How can I save a model, such that signals arent sent. (post_save and pre_save) ...

same project, multiple customers git workflow

Hi, After my first question, id like to have a confirmation about the best git workflow in my case. I have a single django project, hosted at github, and differents clones with each his own branch : customerA, customerB, demo... (think websites) Branches share the same core but have differents data and settings (these are in gitignor...

How to iterate over columns of an image?

I want to transform images like this to add an effect to pictures in django as described here. I decided to implement it as a process for the great django-imagekit/photologue My knowledge of PIL isn't very good, so my question is How to intend a column of pixels by a sinus-offset in PIL? any hints (code, lins, general thoughts) ar...

In Django, How Do I Move Images When A Dynamic Path Changes?

I have a Django app with an image field (a custom ThumbnailImageField type) that auto-generates the file path for an image based on the title, type, and country of the item the image is attached to (upload_ to = get_ image_path). Here's how: def get_image_path(instance, filename): dir = 'images' subdir = instance.get_type_disp...

Showing Model properties from Django on Admin

I have a model using the GeoIP library to render the country of the IP address for that record: class PageIP(models.Model): """ Detail of page """ ip_address = models.IPAddressField(blank=True,verbose_name="IP Address") def _client_country(self): g = GeoIP() return g.country(self.ip_address) client_country = property(_client_...

Integrating Photologue

I want to integrate photologue with my Django app and use it to display photos in a vehicle inventory...kinda like what is offered by Boost Motor Group Inc. I've already integrated the app so the next step which I'm trying to figure out is how to hook it up into my vehicle model and also how to display the photos. My vehicle model looks...

Django ForeignKey(User), autocomplete

When some user create an object in the admin panel, I want that the author field of that object to be the user's name (The user that created it). How can I do it ? I have something like this : author = models.ForeignKey(User) I want to know what user created each object. ...

Java or Django for Liferay?

Hi, I would like to get an opinion what language is better to use with LifeRay. I would like to build some app that I would like to integrate with LifeRay. What language do you suggest would I learn first? Java? - A friend suggested that Java and LifeRay goes well. Django? - I recently new this and seen the overview I find this pretty...

How to validate/clean() a unique=True field without using a ModelForm?

In a custom Form, how does one validate a Model's field's uniqueness (i.e., has unique=True set)? I know that django's ModelForm automatically performs a validate_unique() function that is called within the BaseModelForm's clean() method -- so, when using ModelForm, this will be handled correctly (as it is in the Admin). However, I a...

How to make complex contains queries in Django?

Hi, I need to make query like this: WHERE Comment like '%ev% 3628%' or Comment like '%ew% 3628%' the number '3628' is a parametr. So I've tried in my view: First try: wherestr = "Comment like '%%ev%% %s%%' or Comment like '%%ew%% %s%%'" % (rev_number, rev_number) comment_o = Issuecomments.objects.extra(where=[wherestr]) ...

Does django-tagging 0.3 work with django 1.1?

I've got a django 1.1 application for which it would save a lot of work to use django-tagging. I've added a TagField() to the model. Provided I don't register the model I can save instances of the model. But when I register the model tagging.register(mymodel) Then save an instance it fails thus: Traceback (most recent call last): ...

Secure communication between django server and iphone app

I'm writing an iPhone application that needs to send small bits of information (two strings of under 128 characters each, at a time, and this doesn't happen too frequently) to a server when users interact with it. I would like this information to remain confidential, so I'm thinking of some sort of encryption or secure connection would b...

How to organize Django project with abstract models.

I have a few models: 'Article, Video, BlogPost, News, Commodity'. Each are in their own application. They all are basically the same models with a few extra fields on each. But each share about 15 fields. I'm using an abstract base class. I'm trying to figure out how I should do organization for this. My current setup is like this: app...

Django Widget Media doesn't work

Hi! I need a widget, which should only display a block, because i will add functionality with jQuery. I am trying to include the javascript and stylesheet trough the "Media" class of Widget and it doesn't work for me. Here is the code: class StarsWidget(Widget): """ Widget with stars for rating """ class Media: ...

django - eliminating duplicate related items

Here's a snippet from my application: class PortolioItem(models.Model): ... user = models.ForeignKey(User) contract = models.ForeignKey(Contract) quantity = models.IntegerField(...) ... class Contract(models.Model): ... market = models.ForeignKey(Market) ... You can see that a User has the same number ...

How to override and call super for response_change or response_add in django admin

I would like to override response_change in a ModelAdmin in order to update a field in the parent window. After doing the update, I'd like to give control back to the overriden response_change. A simplified version of what I have tried is: class MyModelAdmin(admin.ModelAdmin): def response_change(self, request, obj): // per...

Django: Translating a string without using language session/cookie

Is there a way in django to translate a string to another language than the one specified in the language session or cookie? I mean doing it while calling ugettext. Something like this, where 'en' is the language code: from django.utils.translation import ugettext as _ def translate(): translated_string = _('Translate me', 'en') ...

how do I get only the time in models

How do I format datetime to give me only the time in my model ...

Apache lags when responding to gzipped requests

For an application I'm developing, the user submits a gzipped HTTP POST request (content-encoding: GZIP) with multipart form data (content-type: multipart/form-data). I use mod_deflate as an input filter to decompress and the web request is processed in Django via mod_wsgi. Generally, everything is fine. But for certain requests (dete...

Custom form in inline form

I have a custom form to display goals. Goals are edited inline in a Game. class GoalForm(forms.ModelForm): class Meta: model = Goal def __init__(self, *args, **kwargs): super(GoalForm, self).__init__(*args, **kwargs) self.fields['goal_scorer'].queryset = Player.objects.filter(gameroster__game=self.instance.g...