django

json jquery grid (using django) - having problems presenting the data

Hi, I'm trying this source where jqGrid gets some json data from django: link Unfortunately the data is not presented in the jqgrid, only an empty jqgrid. I'm rendering the jqgrid with this call: <script type="text/javascript"> $(function () { $.getJSON("{% url myapp.views_json.grid_config %}", function(data){ ...

Django primary key

When querying in djangop say People.objects.all(pk=code) Pk=code .Wht does it mean...... Thanks........ ...

Django admin, filter objects for inline formset

I've got an inline formset and I would like to exclude some model objects from being displayed in the formset. For eg. there is model B which has foreign key to model A, so it is a 1:n (A object has many B objects) relationship. Now on A admin edit page I've got inlines of B. I wonder if it is possible somehow to filter the list of B o...

Why do I need the DJANGO_SETTINGS_MODULE set?

Every time I log on to my server through SSH I need to type the following: export DJANGO_SETTINGS_MODULE=settings if I do not any usage of the manage.py module fails My manage.py has the following added code: if "notification" in settings.INSTALLED_APPS: from notification import models as notification def create_notice_type...

Django QuerySet API: How do I join iexact and icontains?

Hello, I have this join: lawyers = Lawyer.objects.filter(last__iexact=last_name).filter(first__icontains=first_name) This is the site If you try Last Name: Abbas and First Name: Amr it tells you that amr abbas has 1 schoolmates. But if you try First name only it says that there are no lawyers in the database called amr (obviously t...

Django templates: How do I use a field in the model in a template?

Hi, In this template, <body><p>You searched for: <strong>{{ first }} {{ last }}</strong></p> {% if lawyers %} <p>There are {{ lawyers|length }} schoolmates of <strong>{{ first }} {{ last }}</strong> in the database:</p> <ul> {% for lawyer in lawyers %} <li> {{ lawyer.first }} {{ lawyer.last }} {{ lawyer.firm_na...

Two forms in django templates without conflict

hi, I'm creating a template with two different forms but I have the following problem: when I submit the first one the second is also validated and get validation errors. What can I do to avoid this conflict? Thanks and sorry for my english. ...

django - 3-model set all, with joining?

I have these models: class A(Model): pass class B(Model): the_a = ForeignKey(A) class C(Model): the_b = ForeignKey(B) somewhere in code, I have an A instance. I know how to get all of the B's associated with A; A.b_set.all() - but is there a way to get all of the C's associated with all the B's associated with my A, without...

Help creating model for Django app

Hello, I'm trying to make a childcare administration app with Django but I've some problems with the payments code. Each kid has to pay monthly 10 times a year. These payments have some particularities: Some kids could pay a different amount of money depending on the economical situation of the parents. The amount of the payments coul...

Can you explain this code?

I was studying cnprog (a django clone of stackoverflow) and came across this code: class Comment(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') user = models.ForeignKey(User, re...

Django/Python mailing list implementation

Hello everyone My site requires sending periodic update emails to all our registered clients. To keep our lists clear, I want to track all failed deliveries and purge the mailing lists accordingly. I am assuming I am not the first nor the last to do this. Can anyone recommend an existing app/library that I can use to accomplish this ...

Django/Python: How do you start a new process in Python?

After a customer uploads an image I want to re-size an image to 8 different sizes and then send them up to S3 and save them to the file system. Obviously this could take a long time (seconds) and I would want to do it in a "multithreaded" way (I quote that because I don't care if it's actually multithreaded or if it's some other function...

Python/Django: Can a process keep running after the user sees the "Thanks. You're done!" page.

I'm trying to understand threading better. If I create a program that allows people to upload a photo and then I create a new process to resize the image in a hundred ways (taking 5 seconds or longer), and the main program returns a response HTML page to the user saying "Thanks. You're done!", can the other process still be working at th...

Iterating over a large Django queryset while the data is changing elsewhere

Iterating over a queryset, like so: class Book(models.Model): # <snip some other stuff> activity = models.PositiveIntegerField(default=0) views = models.PositiveIntegerField(default=0) def calculate_statistics(): self.activity = book.views * 4 book.save() def cron_job_calculate_all_book_statistics(): ...

Django + NGINX URL Problem

I have set up Django's FastCGI + NGINX, but it's only working for root url: any request to http://example.com/anything redirects to http://example.com. Django's internal server working fine, NGINX static file serving and FastCGI processing of the root URL is fine, error log is clear. Here is my config's server section: server { ...

Load and Reuse Django Template Filters

Is it possible to load a django template tag/filter to use as a function in one of my template tags? I'm trying to load up some of the django.contrib.humanize filters so I can apply them to the results of some of my custom template tags. I can't seem to import them at all, and I don't want to have to rewrite any of that code. ...

Django queryset that returns all unassigned fks

I have 2 models with a 1-1 relation (essentially a resource pool). For the example code, I will simply use nuts and bolts. There will be many more nuts (available resources) than bolts (which will each require 1 nut). However, if a nut can only be assigned to one bolt. The constraint is easy enough to set up with the unique=True name...

In Jinja2, how can I use macros in combination with block tags?

I'm a front end developer, and I've been trying to get a hang on using Jinja2 effectively. I want to tweak a current site so it has multiple base templates using inheritance, it fully uses block tags to substitute content and override it, and uses macros to support passing of arguments. My base template contains this code (edited for si...

Anyway of making Django CMS pages to be only accessible (site side) to only a select few?

I've installed Django CMS (http://www.django-cms.org/) and it's almost perfect. I've been chatting on the IRC #django-cms group and it's been confirmed to me that I can't have access restricted to the pages I make in Django CMS to only a select few on the site side. I know of the CMS_PERMISSIONS setting, but this seems to only restrict ...

django.core.mail send_email with secure connection

Hi Im trying to use django send_email function but it fails on authentication. In fact, django returns me message along the lines - ssl not found in this django installation. I do have ssl-1.15 on my pythonpath and i could import it without errors. So the problem is probably with the certificates, right? Now is there some kind of tut...