django

django-orm case-insensitive order by

Hello all, I know, I can run a case insensitive search from DJango ORM. Like, User.objects.filter(first_name__contains="jake") User.objects.filter(first_name__contains="sulley") User.objects.filter(first_name__icontains="Jake") User.objects.filter(first_name__icontains="Sulley") And also, I can fetch them as user_list = User.objects...

Django Filtering MySQL Warnings

Hi all, Before you all point me to here and here mine a bit different. So I started getting the famous error after shifting to my production server. django/db/backends/mysql/base.py:86: Warning: Data truncated for column 'slug' at row 1 The first thing I did was start googling this after I fixed the problem. To fix this, I tweak...

Issue with change_view save redirect

I am attempting to change the redirected for the django admin save button. What I pasted below works on saving an already existing entry (updating) but not on saving a new one. Any thoughts? def change_view(self, request, object_id, extra_context=None): result = super(TodoAdmin, self).change_view(request, object_id, extra_context) ...

Django Admin: how to display fields from two different models in same view?

My site makes use of Django's User Authentication User model and a custom UserProfile model to store some additional data (birthday, etc.). Is there a way to create a view in Django admin that weaves together fields from both the User and UserProfile models? I suspect that this code snippet is not even close, but maybe it will help illu...

i want Page Counter for django

Hello >>>> i want make page counter to display the number of visitors who have viewed a page on my site ...

Does Django has testing tools comparable to what Rails has?

Hey, Ruby/Rails enjoy some really nice and powerful testing frameworks like Cucumber and RSpec. Does Python/Django enjoy the same thing (I'm not talking about simple unit testing like PyUnit)? Thanks for help and time. ...

Django admin: deletion of linked elements

hi, in Django admin site when you decide to suppress an object, all the linked element (ie: elements pointed at by a foreign key) are also deleted. How do you dodge this, except making raw queries in the shell? Is it possible to tune the admin to have the choice? Thanks ...

Django template filter to create an list of items that join on commas and end on "and"

I feel like I am writing something that should already exist. Does Django have a template filter that joins a list of items on commas and places and 'and' before the last one? For example: a = ['foo',] b = ['bar', 'baz',] c = a + b d = c + ['yourmom',] The filter I am looking for would display each list in the following ways: a...

Required boolean field?

I've got a boolean field, is_operable = BooleanField(widget=RadioSelect(choices=YES_OR_NO, renderer=InlineRadioFieldRenderer), required=False, initial=True) Which is rendered as two radio buttons (yes or no), but I want it to be required. The problem is that if I change it to required=True, it throws a validation error when it gets Fa...

Django template tag to return IP Address?

I need to write a simple Django template tag that will display the user's IP Address? ...

Where does django dev server (manage.py runserver) get its path from?

I recently moved a django app from c:\Users\user\django-projects\foo\foobar to c:\Python25\Lib\site-packages\foo\foobar (which is on the python path). I started a new app in the django-projects directory, and added foo.foobar to the INSTALLED_APPS setting. When I try to run the dev server (manage.py runserver) for my new app, I get the e...

In django, are all session data deleted if a user logs out?

I need to track some information on users, but would like to retain it for a fixed time period, say a week. If I set this value via request.sessions, and the user logs out, can I retrieve it if they log back in later? This all assumes that my sessions are normally set to expire in 30 days, if the user neVer logs out. While thinking ...

Case Insensitive Translation

I'm displaying certain strings in my app in some places as regular case and in some places as upper case: {% trans item.name %} {% trans item.name.upper %} I'm specifying translations using the .po/.mo files: msgid "Welcome" msgstr "歓迎" And the translation seems to be case-sensitive. 'Welcome' gets translated to '歓迎' but 'WELCOME...

GAE+Django server getting called twice for every request

I am running a GAE server with django (locally on my dev machine). The view corresponding to every requests is getting called twice. any idea on how to orrect this. I am using firefox 3.6.8 on ubuntu 9.10 for this. the following is the debug output -> http://pastebin.com/4CetCK5J ...

Django Error: TemplateSyntaxError:

Hello, Trying to get massivecoupon running and am running into a bunch of errors. The most recent is: File "/home/usr/.local/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module import(name) TemplateSyntaxError: Caught ImportError while rendering: No module named libsmassivecoupon.countries ...

Querying Many to many fields in django template

This may not be relevant but just wanted to ask, IF an object is passed from views to template and in the template will i be able to query many to many fields Models code: class Info(models.Model): xls_answer = models.TextField(null=True,blank=True) class Upload(models.Model): access = models.IntegerField() info ...

I need some help understand Django form validators

I've read the Django documentation here: http://docs.djangoproject.com/en/dev/ref/forms/validation/ I've also browsed a number of search results on Google and Stack Overflow, but I haven't been able to answer my questions below. As an example, say I have a model named "Widgets" with a CharField named "product_name". Now say that I wa...

Django blocktrans error

I am nearing the final stages of a project and have run into a bit of a hiccup with Django. It relates to the {% blocktrans %} tag. How do I enable it to be fully functional in my app, currently if I wrap a piece of text in {% blocktrans %} I get a TemplateSyntaxError message I have the following in my TEMPLATE_CONTEXT_PROCESSORS = ...

Creating read-only fields for admin panel in Google app engine and Django

Hi all, How can we create read-only or the non-editable fields in the admin panel? Following is a code snippet from my model: class AnswerVote(db.Model): answer = db.ReferenceProperty(Reply,required = True,editable= False) vote = db.BooleanProperty(default = False,editable= False) voter = db.ReferenceProperty(User,editable= Fa...

How to display a verbose name for models in Django's admin

I registered an app to the django admin with: from django.contrib import admin from MyProject.myapp.models import Model1, Model2 class HyperlinkAdmin(admin.ModelAdmin): pass class Model2Admin(admin.ModelAdmin): pass admin.site.register(Hyperlink, HyperlinkAdmin) admin.site.register(Model2, Model2Admin) Model1= class Hyperlink...