2
голосов
1ответов
82 просмотров

how do I get only the time in models

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

3
голосов
1ответов
687 просмотров

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(): tran...

3
голосов
2ответов
4166 просмотров

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

1
голосов
1ответов
139 просмотров

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

10
голосов
3ответов
10741 просмотров

Django Widget Media doesn't work

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

5
голосов
3ответов
1651 просмотров

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

9
голосов
3ответов
4087 просмотров

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

2
голосов
4ответов
623 просмотров

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

1
голосов
3ответов
1482 просмотров

How to make complex contains queries in Django?

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

13
голосов
2ответов
14865 просмотров

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

1
голосов
6ответов
2872 просмотров

Java or Django for Liferay?

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

1
голосов
1ответов
519 просмотров

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.

4
голосов
2ответов
2985 просмотров

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

0
голосов
1ответов
341 просмотров

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

1
голосов
1ответов
338 просмотров

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 = 'i...

1
голосов
1ответов
441 просмотров

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

5
голосов
4ответов
1934 просмотров

same project, multiple customers git workflow

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

30
голосов
5ответов
6077 просмотров

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)

3
голосов
3ответов
2200 просмотров

Date format for django's SelectDateWidget

SelectDateWidget is very convenient but it normally seems to return dates in the format "%Y-%m-%d". It doesn't take a format parameter and doesn't have much documentation. Anyone run into this or have an idea how to work around it to get the output of the date into another format? There is this t...

12
голосов
3ответов
21722 просмотров

Django form with just a BooleanField

I'm rather new to Django and I'm using Django 1.0. I have this: forms.py: class MyForm(forms.Form): extra_cheeze = forms.BooleanField(required=False, initial=False, label='Extra cheeze') views.py: def order_someth...

1
голосов
2ответов
1948 просмотров

ManyToManyField present in template?

I have 03 models book->target_readers and book has collection. class Book(models.Model): def __unicode__(self): return "%s (%s)" % (self.title, self.reference) reference = models.CharField(max_length=100) title = models.CharField(max_length=200) collection = models.For...

1
голосов
2ответов
1818 просмотров

Saving ForeignKey objects in Django

I'm completely stumped as to why this isn't working: flight = Flight.objects.get(pk=flight_id) print "old", flight.route.pk ## `route` is a ForeignKey field to model Route print "new", new_route.pk flight.route=new_route # new_route is a newly created Route object flight.save() print "db", Flig...

1
голосов
1ответов
115 просмотров

After submitting form, the value is different due to encoding? (Python)

I am using Django. In a regular form, the user enters "Gerry & Pacemakers". (Notice the Ampersand sign.) When I go views.py... def myview(request): q = request.GET.get('q','').strip() print q q is "Gerry"...but it's supposed to be "Gerry & Pacemakers"...encoded Is the correc...

58
голосов
2ответов
51254 просмотров

multiple django sites with apache & mod_wsgi

I want to host several sites with under the same server which uses Debian 5, say I have site1, site2 and site3, and assume my ip is 155.55.55.1: site1: 155.55.55.1:80 , script at /opt/django/site1/ site2: 155.55.55.1:8080, script at /opt/django/site2/ site3: 155.55.55.1:8090, script at /opt/dja...

0
голосов
3ответов
791 просмотров

Send data to server

I am developing an app for the iphone.The thing is that i want to send the values of longitude and latitude i get from the phone using javascript to a server commanding it to search for something.Do i have to read about cross domain stuff? How could this be done? I know that i can use Ajax but it...

14
голосов
2ответов
6363 просмотров

Tutorials on writing custom Django widgets?

I'm trying to modify the Django Admin interface. I need a custom type of textbox that does some pre/post processing on the text. If I understand correctly, a custom widget is the way to go about this. Any good tutorials on how to write custom widgets for Django?

5
голосов
4ответов
2281 просмотров

Using Python locale or equivalent in web applications?

Python's locale implementation seems to want to either read the locale from system settings or have it be set via a setlocale call. Neither of these work for me since I'd like to use the capabilities in a web application, where the desired locale is the user's locale. And there are warnings in t...

0
голосов
4ответов
481 просмотров

Problem with ajax/jquery and django

I want to send a value to the server.I send it using: $.post("http://127.0.0.1:8000/search/",{'long':"30"}); and my views.py is: def search(request): lon = request.POST.get('long','') place = Places.objects.filter(longtitude__icontains=lon) if place is not None: re...

0
голосов
2ответов
655 просмотров

Use Choices from Models in a template tag

I have a model with a bunch of choices, that are in the DB configured as below. COL_CHOICES =( (1, 'Not Applicable'), (2, 'Black'), ) COL2_CHOICES =( (1, 'Green'), (2, 'Blue'), ) etc. I want to display all these options as a men...

6
голосов
4ответов
2521 просмотров

django tracking recent online users

Is there any way to track active users in django? I have seen a few online solutions to the problem: http://mpcabd.igeex.biz/get-online-users-in-django/ being one of those. But it seems rather odd to modify the model structure just to solve this simple problem. I would like to know if there is...