django

how show personalized error with get_object_or_404

Hi guys, i would like to know how show personalized error with get_object_or_404?, i dont want the normal http404 pages, i want to display a message with the result is none thanks :) ...

Django Apache static files

I have a couple of conceptual questions: regarding serving static files (media) in Django in production. I understand that Django serves static files in development different than in production: read this: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-media-files http://docs.djangoproject.com/en/dev/howt...

django forms - edit object after form submitted the first time

I am using django forms to add a new objects to the db. The code I currently have is: if request.method == 'POST': form = MyForm(data=request.POST) if form.is_valid(): obj = form.save() else: form = MyForm() return render_to_response('reflections/add_reflection.html', {'form':form},context_instance=RequestContext...

Django - How to share configuration constants within an app?

It is sometimes beneficial to share certain constants between various code files in a django application. Examples: - Name or location of dump file used in various modules\commands etc - Debug mode on\off for the entire app - Site specific configuration What would be the elegant\pythonic way of doing this? ...

URL updating on login using django

Hi , I have started using django very recently . I am building a service with user login. Login , I am sending as POST service. There is a template to render , once the user is logged in. But the browser address is not getting updated. eg : abc.com the root my form would be something like "form action="/login" .....>" ...

Django custom filters not working in included templates

Not sure if I've done something wrong but if I try to use a custom filter in an included template fragment I'm getting "invalid filter" If I try the filter on the main template it works fine. Is this a known limitation/bug? ...

Django: Save to a many-to-many field in a ModelForm's save() method?

I'm writing a webblog app in Django. I currently have 2 models Post and PostMeta. Post is a standard post style model with fields such as author, title, content etc. It also contains a single many-to-many field called post_meta which is associated with my second model PostMeta. PostMeta is a simple name/value model with two fields, meta_...

Django Simple Search Form

I am running through a tutorial where I am supposed to create a simple search form This is the views.py: from django.http import HttpResponse from django.template import loader, Context from django.contrib.flatpages.models import FlatPage def search(request): query = request.GET['q'] results = FlatPage.objects.filter(content_...

django: recursion using post-save signal

Here's the situation: Let's say I have a model A in django. When I'm saving an object (of class A) I need to save it's fields into all other objects of this class. I mean I need every other A object to be copy of lat saved one. When I use signals (post-save for example) I get a recursion (objects try to save each other I guess) and my...

Are there any php frameworks contain small webserver and rich console tools like RoR/Django?

In Ruby on Rails, I can start my web application, just write in console: script/server. RoR contains small webserver and rich console tools, but I didn`t meet such tools in php frameworks. Are there any php frameworks contain small webserver and rich console tools? ...

Is it possible to add a single row to a Django form?

I have a form along the lines of: class aForm(forms.Form): input1 = forms.CharField() input2 = forms.CharField() input3 = forms.CharField() What I'm hoping to do is add an additional input3 to the form when the user clicks an "add another input3". I've read a bunch of ways that let me add new forms using formsets, but I don't w...

AttributeError: 'WSGIRequest' object has no attribute 'session'

Hello, I keep getting this error at random times and whenever I touch the django.wsgi file, it gets fixed only to happen again after a few hours. I'm lost as to what to do. my middleware_classes is as follows: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', ...

how do i use django dajax framework with jquery ajax events

Currently i am implementing the front-end of a djangoproject we have here. and we use Dajax (more precisely the Dajaxice) framework. i don't know the framework, other than simply calling the server (which other developers here have setup with services that i can call to fetch all data) it seems though that the dajaxice framework, does ...

Where's the primary key of the object I want to update in django using modelform?

I'm using modelform in django to insert and update objects in my database, but when I try to update I cannot see the primary key/id of the object being updated: My model: class Category(models.Model): name = models.CharField(max_length=20, db_index = True) and my form: class CategoryForm(ModelForm): class Meta: model...

Django: Custom widget that can pre-fill from POST/GET data

Updated with my final solution, below. I wrote a custom Django form widget to create a range query. It renders two input fields to define the min and max values for a query. With well-crafted forms and widgets, fields can be filled with the values from the last query like so: form = my_form(request.GET) However, I cannot figure ou...

django admin panel changelist submit

I have used list_editable setting to make several fields editable on my model in the admin panel. The problem is, that when I edit the values and hit Enter, the browser behaves as if I clicked Go button next to actions drop-down list. I get the javascript popup warning: You have unsaved changes on individual editable fields. If you ru...

Django: get URL of current page, including parameters, in a template

Is there a way to get the current page URL and all its parameters in a Django template? For example, a templatetag that would print full URL like /foo/bar?param=1&baz=2 ...

How to render a Django form with RadioSelect without getting a checked radiobutton by default?

On Django 1.2.1 I'm using ModelForm and generating a form with radiobuttons: class myModelForm(ModelForm): class Meta: model = myModel widgets = { 'choose': RadioSelect(), } This generates an extra input with bogus value: <li><input type="radio" id="id_choose_0" value="" name="choose1" />...

Why does django complain that I have not set my ENGINE yet?

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'djangobb', # Or path to database file if using sqlite3. 'USER': 'root', # Not used with sqlite3. 'PASSWORD': 'ro...

Override "remaining elements truncated" in Python

I'm using the Python shell in Django to make some queries. The results keep getting truncated. I get the message, "remaining elements truncated." How can I see all the results? Or, how can I write the results to a file? ...