django

Django + GAE (Google App Engine) : most convenient path for a beginner?

Some background info first: Goal: a medium-level complexity web app that I will need to maintain and possibly extend for a few years. Experience: good knowledge of python, some experience of MVC frameworks (in PHP). Desiderata: using django and google app engine. I read extensively about the compatibility issues between GAE and Djang...

Django query help needed

If I have a database like one in the aggregation example in the django documentation. http://docs.djangoproject.com/en/dev/topics/db/aggregation/ How do I write a query that lists the the average number of books each publisher has published? ...

Django URL Parameter Key Used Twice

I have a simple Django view that just returns URL parameters, but if I use the same parameter key multiple times, I cannot seem to access it. Consider the following set-up: urls.py: (r'^header/$',header) View function: def header(request) return render_to_response('header.html',locals(),mimetype='text/plain') Template: {{ req...

Django: Sort order the list in objects

I have list1 in order by id. Like this: ['4','2','1','17'] #edited How to get list2 from object Entry in order of list1. In the case Query ValueList, as well as on the question. [u'4', u'2', u'1', u'17'] Because some properties are not in QuerySet Thanks for your answers ! ...

Calculating average age in Django

I need to find out average age of items (groupped by various criteria, but it does not seem to be the issue). However I fail to find how to effectively create aggregation over DateTimeField using Django (on top of MySQL). Pure Item.objects.all.aggregate(Avg('created')) seems to produce absolutely bogus values (eg. 20081988007238.133) an...

Is there an IntelliJ Python plugin for the community edition?

I've been playing with the community edition of JetBrains ItelliJ IDEA since it came out, and I really like it; however, a lot of plugins seem to require the ultimate edition (or at least I think they do because of the com.intellij.modules.ultimate dependency). Is there a python plugin that doesn't require the ultimate edition? I'm devel...

Pass model from url to create_object generic input view

I have multiple models that I want to create generic inputs for. My first pass used two separate urls: url(r'^create_actor/$, create_object, {'model': Actor, 'template_name': 'create.html', 'post_save_redirect': '/library/', 'extra_context': {'func': 'Create Actor'}, 'login_required': 'True'}), url(r'^create_movie/$, create_object, {'...

Initialize foreign key drop downs

I want to populate two foreign key fields in one of my forms. The relevant bit of code is as below: if request.method == 'POST': form = IssuesForm(request.POST or None) if request.method == 'POST' and form.is_valid(): form.save() else: form = IssuesForm(initial={'vehicle': stock_number, 'addedBy': request.user, }) ...

Configure the Django development server (./manage.py runserver) to handle wildcard sub-domains?

Can you configure a Django development server to handle wildcard sub-domains? I need to test any arbitrary sub-domain on my dev server and this is not possible by modifying the /etc/hosts/ The subdomain actually controls key behavior on the site (each user gets their own sub-domain and a user can have access to multiple sub-domains req...

How do you Django Query filter through a processed Model column?

I have the following model: class Artist(models.Model): cell_phone = models.CharField(20) pr_phone = modelsCharField(20) In my template, I can search for all artists for whom the entered phone number match their cell phone or PR phone. Assuming there are no restrictions on how the phone numbers have been initially entered, tha...

Does an HTTP Session always require a Cookie?

I'm guessing Yes, but I'm not sure. Both Authenticated Sessions and Anonymous Sessions would reference the stored sessions via the cookie. ########### edit: Clarify It seems that sessions require some way of referencing for the stored session data. This reference could be stored in a cookie OR added as a parameter in the URL. ...

In Django, how do I make my sessions persist through http://mydomain.com and http://www.mydomain.com?

If I set a session in mydomain.com, it doesn't work on www.mydomain.com. I'd like all subdomains, and all www, to be treated as one big thing. mydomain.com and all its subdomains should have all the session cookies of everything. Do I change this in Apache2? edit I think I found the solution: SESSION_COOKIE_DOMAIN = ".mydomain.com" ...

Django - Get Foreign key objects in single query?

I'm finding django foreign keys a bit confusing, is there any way to do the view below, using a single query? # Model class Programme(models.Model): name = models.CharField(max_length = 64) class Actor(models.Model): programme = models.ForeignKey(Programme) name = models.CharField(max_length = 64) # View def list_actors(...

How do I know if jobs have been/are performing? - Crontab

I have followed the suggestion in this question as I am using Django, I have set the script to store date and time of each run of the script in the db, but no entry has been stored yet in the database. Is there a way to figure out, other than typing "top" and searching through? ...

Django url.py Different view functions with the same regex name pattern

I'm filtering a few categories (cat1, cat2, cat3) to be rendered by different views then all the rest by other view functions. It is getting unwieldy to keep adding category slugs to the urlpatterns each time one is added. Can I factor that part out of the regex some how? urlpatterns = patterns('catalog.category_views', (r'^(?P<ca...

Any early impressions of PyCharm for Python, Django and web development?

I just discovered PyCharm, which is a Python/Django/web IDE currently in "public preview" being developed by JetBrains. Has anyone been using it for the last month it has been available, and if so, what are your impressions of it compared to other IDEs that are available such as: Komodo Wing IDE Eclipse + Pydev Aptana ...

RESTful interfaces in Django

Hey, I'm willing to build a restful service using Django, I'm coming form RoR background and facing some problems that could be defined using the following questions: What package do you recommend to use to have RESTful interfaces? Is there a way to make nested resources like a post HTTP request to /posts/post_id/comments that adds a ...

How do I access the request from the request_finished signal callback?

How do I obtain and use the HttpRequest using the request_finished signal? Interested in extracting the url for logging purposes. Current code looks something like this: import logging def write_to_file(sender, **kwargs): logging.debug(type(sender)) logging.debug(dir(sender)) from django.core.signals import request_finished ...

mod_wsgi excessively slow at startup?

I'm developing a django website which for production uses mod_wsgi - there are barely any visitors so anytime I visit it seems mod wsgi starts up and opens the python processes - it takes about 1-2 entire minutes for it to fully load. Is there anything I could do to not make it slow on initial startup? Is this a common problem or could ...

Getting info from all related objects in django

I'm trying to do something pretty simple, but I'm new to Django. I have a quiz system set up for an experiment I'm running. The relevant entries in models.py follow: class Flavor(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Passage(models.Model): name = models.CharFie...