django

Custom authentication with django?

Because I didn't want to use Django's in-build authentication system (maybe I should do, please tell me if this is the case), I created a simple little auth class: import random import hashlib from myapp import models class CustomerAuth: key = 'customer' def __init__(self, session): self.session = session def atte...

Django CharField To String

Hello All, Hopefully a really simple one, possible even stupid! I'm building a tagging system in Django and would like to allow spaces and other characters in the tag name for display but filter them out and use lower case when matching names etc. To that end I have added a field to my Tag model as so: class Tag(models.Model): n...

Django passing a model instance to slightly different model

I'm writing an django app for a project where everybody can change articles but the changes that users commit have to be viewed by someone before they go online. So you see it is a bit like the system used by wikipedia. class Content(models.Model): tp = models.DateTimeField(auto_now_add=True) topic = models.CharField(max_length=...

Python Vs RoR : on Size

I am planning to do a small web application that will be distributed as a single installable. I have plans to develop this application in either Python/Django or RoR. (I am a Java/C++ programmer, hence both these languages are new to me). My main concern is about the size and simplicity of final installable (say setup.exe). I want it t...

django pagination: How to get number of page by id of element in the list

I use django-paginaton app and I'm very glad to use it. Now I need feature, that I don't know how to implement. I have list of elements, that paginated by django's paginator. I have one element with specified id, that I should show, but I don't know what page contains it. I need mechanism jump to the page, that contains my element. I t...

In Django (on Google App Engine), should I call main.py when running Unit Tests?

I have a Django application on the Google App Engine, and I would like to start writing unit tests. But I am not sure how to set-up my tests. When I run my tests, I get the following error: EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined. ERROR: Module: tests could not be imported. This seems pretty straigh...

How do I unit test Django views on the Google App Engine?

I am struggling to run unit tests using the Django Client class on the Google App Engine. I downloaded GAEUnit (v2.0a for Django) and I am trying to use that as my testing framework (maybe I should rather be using something else?) I copy all the GAEUnit files into my project root as instructed, and I modify my app.yaml file. Currently a...

Function not being called in Python, why? and how can I solve it?

Hello, I am currently working on python/django site, at the moment I have a template that looks like this {% extends "shopbase.html" %} {% block pageid %}products{% endblock %} {% block right-content %} <img src="{{MEDIA_URL}}/local/images/assets/products.png" alt="Neal and Wolf News" class="position"/> <div class="products"> ...

Getting distinct rows based on a certain field from a database in Django

I need to construct a query in Django, and I'm wondering if this is somehow possible (it may be really obvious but I'm missing it...). I have a normal query Model.objects.filter(x=True)[:5] which can return results like this: FirstName LastName Country Bob Jones UK Bill Thompson UK David Smi...

Debugging Django from the command-line

I'm working on debugging Django from the command-line. I'm working with django_extensions, and I have IPython installed and ideally I'd like to be able to extract as much information in the shell as possible. How would I go about this task most efficiently? ...

Django - links generated with {% url %} - how to make them secure?

If I want to give an option for users to log in to a website using https:// instead of http://, I'd best to give them an option to get there in my view or template. I'd like to have the link "Use secure connection" on my login page - but then, how do I do it without hardcoding the URL? I'd like to be able to just do: {% url login_pa...

GAE Image Posting to Datastore through Django Form

I'm working on a little side project that involves posting an avatar to a users profile page, seems straight forward enough. I'm following the instructions from the "Using the Images Python API" on the GAE web site. The sample they provide doesn't seem to work with Django though. Searching around here, I found a thread with a similar i...

List, Group multiple instances of an object based on ManyToMany field in Django

Given the following models, I need to return a list of Links for each Place, grouped by Category. class Place(models.Model): name = models.CharField(max_length=100) class Category(models.Model): name = models.CharField(max_length=100) description = models.TextField() class Link(models.Model): name = models.CharField(ma...

Completely disable Django's CSRF protection in SVN Trunk

I've spend a few hours in frustration, trying to disable the CSRF which Django now tries to force on me, to no avail. Had anyone else tried this with more success? I'm fine with anything that works, except for a source patch (but monkeypatches are okay). ...

Django cache_page checking

Hi, How can I confirm my Django views are being cached when I use the cache_page decorator like so: @cache_page(60) def my_view(request): Ideally I would like to output cache hit/miss messages in the console so I can confirm my view is being cached for 60 seconds etc. Many thanks, g ...

how do I filter tags with django-tagging?

I'm using the django app django-tagging and I'm trying to filter out certain tags for a simple tag search. the variable 'tag' is text of some tag I am searching for. 'Widget' is the model associated with the tags. tags = Tag.objects.usage_for_model(Widget, counts=True, filters=dict(tags__icontains=tag)) The code above sort of works. ...

django unprintable templatesyntaxerror object caused by urlconf?

I'm trying to get a django project set up, and I seem to be having trouble with my urlconf. I'm not sure what the deal is, and the error below isn't entirely helpful to me. I don't think it really has anything to do with template rendering, actually, because I stepped through the execution path until just before the render_to_response ...

Django: Serving admin media files

Hi! I am trying to serve static files from another domain (sub domain of current domain). To serve all media files I used this settings: MEDIA_URL = 'http://media.bud-inform.co.ua/' So when in template I used {{ MEDIA_URL }} it was replace with the setting above. Now I am trying to serve admin media files from the same su...

How to have a URL like this in Django?

How can I have URLs like example.com/category/catename-operation/ in Django? Also in some cases the user enters a space separated category, how can I handle that? E.g if the user enters the category as "my home", then the URL for this category will become example.com/my home/ which is not a valid URL. How can I handle these things? ...

Setting up a filter in django

Hi, I'd like to set up a filter in my app...I'd like to have my filters being done in increments, kinda like what is running at this site. So far my filter views are separate (is there a way of combining the filtering logic into one view?) and I'm supposing I'll need some way of saving the chosen filter (possibly sessions...but I'm not...