django

django, extending the add/change form at the admin

Hello, I want to extend the admin panel of Django where adding/changing happens for a specific object, say Foo. I have already done alot of research and found a part discussing this at the old version djangobook. I have made an admin/myapp/foo/change_list.html at my template directory and did some experient such as adding some html and ...

Reversing django.contrib.auth.models.User password, sha1 to readable string

from django.contrib.auth.models import User u = User.objects.get(username='test') user.password u'sha1$c6755$66fc32b05c2be8acc9f75eac3d87d3a88f513802 Is reversing this password encryption possible? ...

How to create translation to "timesince" value ? (template tag)

I review docs but I am lost... some problem with it: {% load i18n %} {% blocktrans %} {{ wpis.entry.lastChangeDate|timesince }} {% endblocktrans %} Raise: `KeyError: u'wpis.entry.lastChangeDate | timesince'` Of course, without blocktrans all works fine. So, what is simples way to translate few words? (I am interesting polish lang...

django : ImportError No module named myapp.views.hometest

I have fecora 11, set django with mod_wsgi2.5 and apache2.2. And I can run "python manage.py runserver" at local. It works fine. I got error when i test from remote browser. Thanks for any suggestion and help! ...

How to generate temporary URLs in Django

Wondering if there is a good way to generate temporary URLs that expire in X days. Would like to email out a URL that the recipient can click to access a part of the site that then is inaccessible via that URL after some time period. No idea how to do this, with Django, or Python, or otherwise. ...

Inserting values into a formset

I have a modelform which has a user_id field that I have excluded from the form. This form is made into a modelformset. The reason I have the user field excluded is because it's not an editable value. I don't want that value to go to the HTML form where it can be tampered with by naughty user. When I try to save this model formset, I ge...

import csv file into mysql database using django web application

thanks guys.i managed to complete it.million thanks again specially for DAVID,WM-EDDIE and S.LOTT.also STACKOVERFLOW The solution: **model = Contact() model.contact_owner = request.user model.contact_name = row[1] model.contact_mobile_no = row[2] model.sele...

How to encode UTF8 filename for HTTP headers? (Python, Django)

Hi, I have problem with HTTP headers, they're encoded in ASCII and I want to provided a view for downloading files that names can be non ASCII. response['Content-Disposition'] = 'attachment; filename="%s"' % (vo.filename.encode("ASCII","replace"), ) I don't want to use static files serving for same issue with non ASCII file names but...

Can't use an inheriting Django model's Meta class to configure a field defined in an inherited abstract model

I would like to use properties from an inheriting model's Meta class to configure a field defined in an abstract model higher up the inheritance tree: class NamedModel(models.Model): class Meta: abstract = True verbose_name = 'object' name = models.CharField("Name", max_length=200, db_index=True,...

Get Foreign Key Value

How can I get the foreign key values? I have a common vehicle model that links to the year, series, engine type, body style, transmission and drive train...all as foreign keys. I'd like to get the values of these fields for my app, but I'm stuck as to how I'd go about them. Any ideas will be highly appreciated. class Model(models.Mod...

Display thousands position

I'd like to display only the numbers that lie in the thousands position for a value i.e. 193000 will be displayed as 193 and so on. How do I achieve this, maybe at the template level? ...

Why does TinyMCE insert <span> </span> between (django) {% %} tags?

My application features a CMS for editing Django templates. Whenever I type something like {% sometag %} TinyMCE will actually store {%<span>sometag</span>%} Is there any way to prevent TinyMCE from doing this? ...

Django: how to retrieve an object selected by the ``object_detail`` generic view ?

Hi (sorry for my ugly english) I wonder if this is possible to retrieve an object which was selected with the object_detail generic view. For example : from django.views.generic.list_detail import object_detail def my_view(request, slug) response = object_detail(request, MyModel.objects.all(), slug=slug, slug_fie...

appengine: NeedIndexError: The built-in indices are not efficient enough for this query and your data. Please add a composite index for this query.

While using django.core.paginator import ObjectPaginator, I'm getting this error: NeedIndexError: The built-in indices are not efficient enough for this query and your data. Please add a composite index for this query. The original query is written in this form: query = models.Cdr.all() query.filter("var1 =", var1 ) query.fi...

Django Admin: How do I know when the user is editing an existing object or saving a new object?

Hi guys, I would like to learn how to work with the Django Admin. How do I know when the user is editing an existing object or saving a new object? For example, if I want to make a function to do something different when the user saves a new object or saves an edited object, how do I know which is which? Thanks guys :) Sorry for my E...

statistical data to HTML tables (filter/sort/aggregate) and charts using django

Hi, I have lots of tables with statistical data (environment related) and wondering if there are any existing django app that will let me quickly produce charts i.e. sort/filter type of functionality. is there any short cuts.. This data will only be used during a temporary event for analyst, so it feels like a lot of tedious task to de...

What's a server equivalent of django.test.client to test external URL fetch?

I'd like to make sure a given view in my test is fetching an external URL properly. It uses urllib2 (but this shouldn't matter, since it's blackbox testing). Perhaps a temporary local server of some kind? Is there an app that does this already? (My Googling has failed me.) ...

Django: mail to gmail errors intermittently?

I've been getting these errors intermittently from sending email from my django app. I send very few emails, so the number of these errors is alarming. Sending email works intermittently as well when doing it by hand : >>> from django.core.mail import send_mail >>> send_mail('Subject here', 'Here is the message.', '[email protected]...

Center Google Map Based on geocoded IP

Basically whenever someones opens up my (Google) map I want it default to their approximate location. Is there an easy way to do it with Google's API or do I have to write a custom code (this is python based app)? ...

jQuery Validation Plugin remote check for password with Django

Hi, I have a "Reset Password" form being validated by the jQuery Validation plugin. Everything works fine except that I can't get the "remote" part to work with Django. What I'm trying to do is to have remote send an ajax request to my Django backend to check that the "Old Password" is correct as part of validation. What I'm not sure ...