django

Equivalent to django Form to show object contents

Is there any Django class used to show the contents of an object model in a non-modifiable way? Something like this for forms to edit the objects from a model: class TestForm(forms.ModelForm): class Meta: model = models.Test using it as: def generic_view(request): form = TestForm() return render_to_response('gener...

How do I get js and css to display in Django?

I've got a template, a.html, which looks like this: <script type="text/javascript" src="jquery-1.4.min.js"></script> <script type="text/javascript" src="reg.js"></script> Why doesn't this work? ...

how do i write this django view('jsonview'),it is used $.getJSON(jquery)

$.getJSON('/jsonView', { tag: "userName", userName: 'zjm1126' }, function (H) { if (H.result == "successName") { F.showOk(h.ok); ...

Is there something similar to 'rake routes' in django?

In rails, on can show the active routes with rake (http://guides.rubyonrails.org/routing.html): $ rake routes users GET /users {:controller=>"users", :action=>"index"} formatted_users GET /users.:format {:controller=>"users", :action=>"index"} POST /users {:controller=>"users", :action=>"cr...

widgets in django admin

I need a widget which can make a foreignkey readonly and also it should display the value related to that field not the id suppose Class A(models.Model): id=models.AutoField(primary_key=True) name=models.CharField(max_length=200) def __unicode__(self): return self.name Class B(models.Model): id=models.AutoField(pri...

How to know requested module name in Django

In Django if a request is made to another module. Can we know where the request has made from through the request variable... In the below example I have to know that the request was made from a.html ort that corresponding module Ex: a.html <html> <form onsubmit=/b> </form> </html> ...

Django/GAE anonymous users data

Hi, in my application I have per-user models, let me explain with a simple example: class Item(db.Model): master = db.ReferenceProperty(User,collection_name="items") name = db.StringProperty() description = db.StringProperty() value = db.StringProperty() def __unicode__(self): return u"%s"%self.name So I can store informations on...

Is it possible to implement a "change password at next logon" type feature in the django admin?

I want to be able to set an option in the user's settings that forces them to change their password upon the next login to the admin interface. Is this possible? How would it go about being implemented? I'm using the default auth model right now but not opposed to modifying or changing it. Thanks for any help. ...

Chat application using django

If i devlop a chat application using django will it have some performance problem? Can i do server push in django? I want to have PM and room discussions as well. ...

Serializing objects containing django querysets.

Django provides tools to serialize querysets (django.core.serializers), but what about serializing querysets living inside other objects (like dictionaries)? I want to serialize the following dictionary: dictionary = { 'alfa': queryset1, 'beta': queryset2, } I decided to do this using simplejson (comes with django). I extended simpl...

Is it possible to have an admin inline without original data being shown?

In the django admin I have a model with an inline. I would like to be able to only show "add new" lines for the inline, and not show any preexisting, original data in the table belonging to the inline. Is this possible? I have tried every combination of max_num and extra, and it always shows existing table data. Thanks ...

Mod_Python + Django library import issue

Hello, I recently had a site that was running perfect for months, all of a sudden it decided to dump itself for no approximate reason. I am running django + mod_python + apache, and the system decided it was time to start ignoring the import of the pycurl library, my intial first thought was that somehow the library had become corrupte...

List variable containing string not getting rendered in Django Template

Hi, I have a list of names, which I render at two different places in a HTML at one place it works fine, the other time it disappears. names= ['a','b','c','d'] In the HTML code I am printing {{names}} this gives me the correct results. When I use the same string in a javascript it stops working but if I replace the variable by...

How to use one app to satisfy multiple URLs in Django

I'm trying to use one app to satisfy multiple url paths. That is to say, I want the url /blog/ and /job/ to use the same app, but different views. There are a number of ways to do this I'm sure, but none of them seem very clean. Here's what I'm doing right now # /urls.py urlpatterns = patterns("", (r"^(blog|job)/", include("mypro...

Django app initalization code (like connecting to signals).

I need a place to run an initialization code that is application specific (like connecting to signals). When I put the code to __init__.py module of an application I've ended up with a circular import of the models. Is there a way to fire a function when the framework is setup and before any request is executed? I use quite old version...

Extended Form silently fails

Hello, SOvians. I have customized one of my forms and now it does not pass the is_valid() test. No form.errors are visible. Any ideas for where I went wrong? Form: class SearchForm(forms.Form): param = forms.CharField(required=False, max_length = 500, label = 'Search for') sets = forms.ModelMultipleChoiceField(queryset=Set.obje...

Fighting client-side caching in Django

I'm using the render_to_response shortcut and don't want to craft a specific Response object to add additional headers to prevent client-side caching. I'd like to have a response that contains: Pragma: no-cache Cache-control : no-cache Cache-control: must-revalidate And all the other nifty ways that browsers will hopefully interpre...

Django - reversing wrapped view functions

I am trying to incorporate django-schedule into my project. Django-schedule's source is here. I don't like the urls, because they all capture a slug. My project will only allow one calendar per user, so it doesn't make sense to capture the slug. So, I wrapped the django-schedule views like this (look up the slug using the current user, a...

Filtering only on Annotations in Django

Taking the example from: http://docs.djangoproject.com/en/dev/topics/db/aggregation/#filter-and-exclude Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count('book')) Is there anyway to have the filter only apply to the annotation, so it would return all publishers, with some having a num_books=0? ...

Django : json serialize a queryset which uses defer() or only()

Now I've been using json serializer and it works great. I had to modify my queries where I started using the only() & defer() filters, like so - retObj = OBJModel.objects.defer("create_dt").filter(loged_in_dt__gte=dtStart) After I've done the above, suddenly the json serializer is returning empty fields - {"pk": 19047, "model": "OBJ...