django

Django request paths

Hello all, I've been working through an issue with my django project. The issue is I've got one project, which will retrieve data for users of different clients. I need to know 'from where' a viewer is coming from (request.path [my original solution]). I've been looking at a number of different options which sound close to what I want t...

django form validation

In my form I have a following regex field : code = forms.RegexField(regex=r'^\d{2}[-]\d{3}', max_length=6, widget=forms.TextInput(attrs=attrs_dict), label="Postal code") how to create clean method for this field checking if the regex requirements are met ? I'd like to have a custom message here, not django's built in (if it gives any)...

Django URL parameters from external apps

I am using Django and I have the following URL in my project's urls.py file. (r'^user/(?P<username>[\w_\-\.]+)/my_app/', include('my_app.urls')), (r'^user/(?P<username>[\w_\-\.]+)/my_other_app/', include('my_other_app.urls')), ... The goal is to have an application that uses the username of a user e.g. a profile application where ever...

Can I raise Http404 in a Django template tag?

I have a Django application that provides template tag profile. The tag accepts a username as its argument. How should I treat the situation when there exists no User instance with the given username? Does it make sense to raise HTTP 404 inside a template tag? Or should I simply pass an empty dictionary to the template? ...

Django Many to Many Record only display last record

Dear All, I have problem with display record from django . multi devices have multi services and others many-to-many model models.py class Service(models.Model): service_name = models.CharField(max_length=25) service_port = models.IntegerField(max_length=6) class Devices(models.Model): hostname = models.CharField(max...

Django + Haystack how to do this search

Hi all, I'm new to Haystack and to the search world so I didn't know how to ask this question. What I want to achieve is the following. Having a search query like: one two I would like to get returned any content like: This one one two two one something one here Is this possible with Haystack + solr/xapian? Is also possible to ha...

how Update column data type in Django...

Hi All, I have new to python and django I am creating poll application and in that application after creating models poll and choice using "South". I want to changer the length of question field from 200 to 300 but I am not able to achieve it even using south as well. I have run python manage.py schemamigration polls --initial command ...

ignoring WARNINGs in Django

Hay, my model is a through a "Data truncated for column 'password' at row 1" warning. This is fine, the data does get truncated, but it get fills back in by a different function later on. How can i get django a ignore this warning? I think it's called on the Save() method. ...

Logging activity on Django's admin - Django

Hi folks, I need to track/log activity on the Django admin. I know there are messages stored by admin somewhere, but I don't know how to access them in order to use them as a simple log. I'm trying to track the following: User performing the action Action committed Datetime of action Thanks guys. ...

Unable to load fixture data in Django tests

I have an app called pta.apps.users which is loaded in the Loaded apps setting in my settings.py. The app works fine, I now want to test it and have placed json files in the fixtures directory inside my users app. I have a test which runs fine but the fixtures wont load. from django.test import TestCase from django.test.client import...

Django: ImageField disable image deletion

Greetings Having an ImageField object in my Foo model as such: class Foo(models.Model): name = models.CharField(max_length=50) photo = models.ImageField(upload_to='foobar', blank=True, null=True) I want Foo to disable to delete the uploaded photo once a Foo object is deleted and a specific . How can I do this? Ie: If self.na...

Django Admin Intermittently Returning 404 On Model Edit

We're using the Django Admin to maintain some data that's exported to a few of our sites. Sometimes when clicking through the standard changelist view to get a model edit form instead of being routed to the correct page we're getting the Django 404 page/template. It was happening somewhat sporatically, and we could for a while reproduce...

Possible to refresh Django connections on the fly?

Is it possible to add a new database connection to Django on the fly? I have an application that uses multiple databases (django 1.2.1), and while running, it's allowed to create new databases. I'd need to use this new database right away (django.db.connections[db_alias]). Is it possible without server restart? Using module reload here ...

Converting SQL into QuerySet for Admin

I have a comment model with a GenericForeignKey. The comments key to content which has a site assignment; they themselves have none. This becomes a problem when certain users should only be able to see comments that belong to sites they can see; that is, comments which point to content that is assigned to a site they can see. Right now,...

How to unit test a form with a captcha field in django?

Hello all, I would like to unit test a django view by sumitting a form. The problem is that this form has a captcha field (based on django-simple-captcha). from django import forms from captcha.fields import CaptchaField class ContactForm(forms.forms.Form): """ The information needed for being able to download """ las...

Deploying Django with no CGI available?

I need to deploy a Django project on a shared server which I have no root access for, and no administration capabilities whatsoever. Each user on the server has a dedicated directory from which Apache serves that users files (public URL would be /~username/). Problem is, Apache on this server has no CGI capabilities, no mod_python, no ...

Iterating through model fields - Django

Hi folks, I'm trying to iterate through fields as they are written down within my model: currently I'm using this: def attrs(self): for attr, value in self.__dict__.iteritems(): yield attr, value but the order seems pretty much random :( Any ideas? ...

Running wave robot inside django app engine patched webapp

Hey, I got a google wave python robot running with an existing django app engine web app. all works well apart from one thing. for some reason i am unable to access my datastore which is the same datastore for the django webapp. i want to read data and store data to the django datastore from the robot. what can i do? ...

django permission issue

Hi Everyone I m dealing with some serious issue in django-admin.I have created models with app_label in class Meta But when i tried to create a group for alloting specific permissions I cant find them in my selection list.But if i remove app_label from my model I can see the model in my permission list.But I cant go without app_label, s...

How to use admin interface if I have no application?

I am creating a Django based app and I'd like to put everything under the root in the following structure: /path/to/my/app/ settings.py models.py urls.py admin.py ... One problem that I run into is the admin interface doesn't include whatever models I have that are registerd in admin.py usin admin.site.register(mo...