django

Traversing multi-dimensional dictionary in django

I'm a PHP guy on my first day in Python-land, trying to convert a php site to python (learning experience), and I'm hurting for advice. I never thought it would be so hard to use multi-dimensional arrays or dictionaries as you pythoners call them. So I can create multi-dimensional arrays using this, but i can't loop it in a django templ...

what is the right way to use the new "--freeze" option in startmigration for django-south?

I've tried the following but this seems to only create an empty migration file: startmigration appname freeze_appname --freeze appname i've also tried just: startmigration --freeze appname doesn't work either. ...

how to include css/javascript in django 0.96 for appengine project

I am using django 0.96 for the appengine project. I wanted to use javascript and css in my html files unfortunately i am unable to do it via django... One solution(which i don't like) is to make my app.yaml something like this: handlers: - url: /media static_dir: static/media But i want it to do with django itself so i avoided using...

Access Django testserver from Django test

Hi! I want to write a unit test that performs HTTP requests directly (instead of using django.test.client.Client). If you're curious why - it's because I want to test a Thrift-over-HTTP API that I expose from my Django application - and I want to use the Thrift client in the unit test. The problem is that during tests, the server is n...

Configuring Django to use SQLAlchemy

how we configure django with SQLAlchemy?? ...

Django on Google App Engine

How much of a pain is it to run a Django App on App Engine? Also, does the Datastore work as-is with Django? ...

Django : Know if property is the default value

How can you know if a value is the default value for a Model's property. For example class Alias(models.Model) : image = models.ImageField(upload_to='alias', default='/media/alias-default.png') a = Alias.get("123") # this doesn't work if a.image == a.image.default : pass # nor this if a.image == Alias.image.default : pass I t...

Django stops printing to stdout

Hi First of all, I'm using Windows, just to make that clear. I am using cmd.exe to manage runserver and the server runs just fine. However, sometimes, on a seemingly random basis, Django simply stops writing to stdout! The server responds to my requests and everything, but nothing gets printed. To make it even clearer, I'm not even tal...

Determining popularity of an item within a given date/time range

I'm working on a django website that needs to track popularity of items within a given date/time range. I'll need the ability to have a most viewed today, this week, all time, etc... There is a "django-popularity" app on github that looks promising but only works with mysql (I'm using postgresql). My initial thoughts are to create a g...

Http verb decorator for Django?

In ASP.NET MVC, you can use the AcceptVerbs attribute to correlate a view function with a verb: public ActionResult Create() { // do get stuff } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(FormCollection collection) { // do post stuff } The Django Book suggests something like this: def method_splitter(request, ...

Django ORM Creates Phantom Alias in SQL Join

Hello, I am executing the following code (names changed to protect the innocent, so the model structure might seem weird): memberships = models.Membership.objects.filter( degree__gt=0.0, group=request.user.get_profile().group ) exclude_count = memberships.filter( member__officerships__profile=req...

Traversing foreign key related tables in django templates

View categories = Category.objects.all() t = loader.get_template('index.html') v = Context({ 'categories': categories }) return HttpResponse(t.render(v)) Template {% for category in categories %} <h1>{{ category.name }}</h1> {% endfor %} this works great. now im trying to print each company in that category. the company table...

Is it possible to override the method used to call Django's admin delete confirmation page?

On Django's admin pages, I'd like to perform an action when the administrator clicks the Delete button for an object. In other words, I'd like to execute some code prior to arriving on the "Are you sure?" delete confirmation page. I realize I could override the template page for this object, but I was hoping for something easier (i.e.,...

saving inlineformset_factory data

@render_to('edit_operation.html') def edit_operation(request, pk): from forms import OpBaseForm, OperationForm from django.forms.models import inlineformset_factory op = Operation.objects.get(pk=pk) OpBaseFormSet = inlineformset_factory(Operation, OpBase, form=OpBaseForm, extra=5, ) if request.method == "POST": form = Oper...

django development add-ons

I have come across various django development add ons, particularly, django-extensions django-annoying django-debug-toolbar django-tools I haven't exactly used all of these. I think it is hard to beat the simplicity and power obtained by the combination of django's pretty error pages combined with iPythonEmbed shell. Which of the...

Django/Python: empty string in HTML rendered result

Given siteInfo = \ { 'appname3': 'MSQuantDynamics11', 'siteBase': 'http://www.pil.sdu.dk/1', } in a "urls.py" file. This works as expected: urlpatterns = patterns('', (r'^$', direct_to_template, \ { \ 'template' : "homepage.html...

PayPal Django

Hello, I am using Django-PayPal plugin (http://github.com/johnboxall/django-paypal/tree/master), which works almost fine with one problem. I followed integration process and think that everything is the same as in the guide. But there is the problem, that I always get the INVALID response flag. I will not be able to determine the sucess...

One django installation different users per site

How can I have different users for different sites with django. My application should look like this: a.mydomain.com b.otherdomain.com Users should be bound to the domain, so that a.mydomain.com and b.otherdomain.com have different users. ...

django- pass a string or an instance in urls.py?

Is there a benefit to passing a string in your url patters vs a function instance? It seems like it could be optimized to not actually load the function until it is needed, but is this in fact true? from django.conf.urls.defaults import * from myapp.views import myView urlpatterns = patterns('', # as a string url(r'^as-string/$...

Django filter versus get for single object?

I was having a debate on this with some colleagues. Is there a preferred way to retrieve an object in Django when you're expecting only one? The two obvious ways are: try: obj = MyModel.objects.get(id=1) except MyModel.DoesNotExist: # we have no object! do something pass and objs = MyModel.objects.filt...