django

Django site_media relative url problem

Hello, in my settings.py I have the following: PROJECT_DIR = os.path.dirname(os.path.realpath(__file__)) MEDIA_ROOT = os.path.join(PROJECT_DIR,'templates') MEDIA_URL = '/templates/' In urls.py I have (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), And my base.html has the f...

IntegrityError with Booleand Fields and Postgresql

I have this simple Blog model: class Blog(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) user = models.ForeignKey(User) is_public = models.BooleanField(_('is public'), default = True) When I insert a blog in admin interface, I get this err...

Could I use urlize filter in this way ?

Could I use urlize filter in this way? : from django.utils.html import urlize def save(self, force_insert=False, force_update=False): self.body = urlize(self.body) super(Post, self).save(force_insert, force_update) body is a TextField. ...

Django blog reply system

hello, i'm trying to build a mini reply system, based on the user's posts on a mini blog. Every post has a link named reply. if one presses reply, the reply form appears, and one edits the reply, and submits the form.The problem is that i don't know how to take the id of the post i want to reply to. In the view, if i use as a parameter o...

How to make a "nested" translation string in Django template?

Here's a phrase I have to make translateable: Poll ends in 2 hours 23 minutes This string must have the main phrase and 'hour' and 'minute' in singular and plural forms. {% blocktrans %}Poll ends in {{ poll.expire_hours }} ??? {{ poll.expire_minutes }} ???{% endblocktrans %} What do I put then instead of ??? ? Solution: made a s...

Web based printing from a Django application?

Is there any recent developments in web based printing? I know using @media print in CSS, PDF based solution or iTextSharp but they are not really easy (except @media print) but alignment is little tricky if receipt contains barcodes or if I have to format for A5 etc., Is there anything new in HTML5 which will support this? I would li...

Building a survey to put in a WordPress website using Python/Django

So I've been given a task to build a survey to get data regarding time slot preferences of prospective students for a particular course. I know there are really quick solutions to this like Google Forms, SurveyMonkey, but since it's not unusually hard, I want to implement the survey myself in a totally new language as an opportunity to g...

jquery; django; parsing httpresponse

hi_all() I have a problem with parsing http response.. I try send some values to client >>>>return HttpResponse(first=True,second=True) when parsing: $.post('get_values',"",function(data){ alert(data['first']); //The alert isn't shown!!! }); what is the right way to extract values from httpresponse ma...

How can join two django querysets in one?

I need order a Queryset by date in desc order, but i need put in the end the objects at the end, I do this: qs1 = Model.objects.exclude(date=None).order_by('-date') qs2 = Model.objects.filter(date=None).order_by('-date') and my list is: l = list(qs1)+list(qs2) There is a more efficiently way for this? ...

Elegant Disjunctive Normal Form in Django

Let's say I've defined this model: class Identifier(models.Model): user = models.ForeignKey(User) key = models.CharField(max_length=64) value = models.CharField(max_length=255) Each user will have multiple identifiers, each with a key and a value. I am 100% sure I want to keep the design like this, there are external reas...

More strict query yields more results?

I've got a query that looks like this affiliates = User.objects.annotate(referral_count=Count('referrals')) .filter(referral_count__gt=0) But when I restrict it more by adding referrals__user__date_joined__gt=start_date to the filter, I get even higher referral counts. I'm trying to count the number of people...

Potential Django Bug In QuerySet.query?

Disclaimer: I'm still learning Django, so I might be missing something here, but I can't see what it would be... I'm running Python 2.6.1 and Django 1.2.1. (InteractiveConsole) >>> from myproject.myapp.models import * >>> qs = Identifier.objects.filter(Q(key="a") | Q(key="b")) >>> print qs.query SELECT `app_identifier`.`id`, `app_ident...

Problem with django admin after upgrade python to 2.6

got this error in adminpage after I try to save something into model TypeError at /admin/some/model/1/ int() argument must be a string or a number, not 'RelatedManager' django 1.2.1 python 2.6.5 os fedora core6 ...

UI Testing Tool on linux

Looking for a tool to UI testing on Linux .Platform used for development is django. The idea is that the analysts will capture the tests thru some UI and it will be able to be played back over and over again. ...

Django QuerySet ordering by expression

How can i use order_by like order_by('field1'*'field2') For example i have items with price listed in different currencies, so to order items - i have to make currency conversion. class Currency(models.Model): code = models.CharField(max_length=3, primary_key=True) rateToUSD = models.DecimalField(max_digits=20,decimal_pla...

Django get old url

In django views,From the request how would we know from which page this view was called def password_change(request): if request.method == 'POST': u=request.user u.set_password(request.POST.get('new_password')) u.save() post_change_redirect= //Need old link here return HttpResponseRedirect(post_change_...

Send encrypted parameters to a view in django

I want to send a project_id veriable in a edit_project view in django. Can any one tell me that how can I do that? ...

Django sitemap intermittent www

The automatic sitemap for my Django site fluctuates between including the www on urls and leaving it out (I'm aiming to have it in all the time). This has ramifications in google not indexing my pages properly so I'm trying to narrow down what would be causing this issue. I have set PREPEND_WWW = True and my site record in the sites fra...

Fixing Django Admin collapse error.

Hi. I've been following the Django tutorial, and so far everything's been working as planned. Except "collapse"ing. On my admin page, I get the error in my Javascript Console: Uncaught TypeError: Object #<an Object> has no method 'first' collapse.min.js:1 I'm assuming this is a bug in jQuery, or the collapse script, however my qu...

Django 1.2: Dates in admin forms don't work with Locales (I10N=True)

I have an application in Django 1.2. Language is selectable (I18N and Locale = True) When I select the english lang. in the site, the admin works OK. But when I change to any other language this is what happens with date inputs (spanish example): Correctly, the input accepts the spanish format %d/%m/%Y (Even selecting from the calendar...