Django template for loop
I have a basic question, in the Django template language how can you tell if you are at the last loop iteration for a "for loop"? ...
I have a basic question, in the Django template language how can you tell if you are at the last loop iteration for a "for loop"? ...
I am trying to create a SlugField in Django. I created this simple model: from django.db import models class test(models.Model): q = models.CharField(max_length=30) s = models.SlugField() I then do this: >>> from mysite.books.models import test >>> t=test(q="aa a a a", s="b b b b") >>> t.s 'b b b b' >>> t.save() >>> t.s 'b ...
If I start python from the command line and type: import random print "Random: " + str(random.random()) It prints me a random number (Expected, excellent). If I include the above-two lines in my django application's models.py and start my django app with runserver I get the output on the command line showing me a random number (Grea...
Suppose there are two (or more) django administrators who have read a database record and then change and save it. There is no database problem, but some administrators are going to be surprised that the record they wrote was overwritten. Is this issue ever addressed? One way would be to have an explicit "edit in progress" button which ...
I am developing some kind of financial market simulation on GAE. Although I have attained much progress, I have begun to consider dismissing GAE and going for a Django + rdbms solution for the last few days. Let me state my reasons: transactions: GAE supports transactions with single entity groups. if an application involves complex tr...
I have a model called Answer which has a ForeignKey relationship to another model called Question. This means there can be several answers to question, naturally. class Question(models.Model): kind = models.CharField(max_length=1, choices=_SURVEY_QUESTION_KINDS) text = models.CharField(max_length=256) class Answer(models.Model...
I'm learning python and my current focus is on web programming. Thx to some help from stackoverflow, I recently made some reasonable progress. While still at basic level, I can now "somewhat" comfortably use html templates, web frameworks (haven't done anything significant yet), sqlite (no mySQL yet), etc. Before I start another proje...
Hi, I have an application called Location. Location has Country, State, City, Big_City_Nearby, Longitude, latitude. I have an application for an item for sell. Item has Title, Link, Description, Price & Location which is a ForeignKey(). Now, if someone wants to see all items for sell in the US, they click on a link (let say http://ex...
I recently found out that I can generate forms from models. I've read the docs and am wondering why someone would opt not to do this in favor creating their own form objects. ...
I know Django 1.1 has some new aggregation methods. However I couldn't figure out equivalent of the following query: SELECT player_type, COUNT(*) FROM players GROUP BY player_type; Is it possible with Django 1.1's Model Query API or should I just use plain SQL? ...
Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it. I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported back ends. Both proje...
I’m just beginning to learn Django and I like the automatic listing in Django admin and the way you can configure filters and what columns to show. Is it possible to use it in my own applications? I’ve looked in the source for the admin and figured out that I probably want to subclass the “ChangeList”-object in some way and use it in my...
Hello, I'd like to have haproxy caching/redirect the /static/.+ url path of my django instances to speed up static file serving. What's the best way to do that? ...
I get the error in question when I attempt to create a project. I followed the instructions found at how to install python an django in windows vista. ...
Hi, I'm trying to figure out how to pass html back to a jQuery call, but for some reason my code refuses to work. t = get_template('success.html') html = t.render(Context({'success': True})) # should render '<p><h1>aoeu</h1></p>' x = "{'success' : '" + html + "'}" return HttpResponse(x) jQuery code: $.post("adduser", data, functi...
Hi, I'm trying to write an init function for one of my models so that I can create an object by doing p = User('name','email') When I write the model, I have def __init__(self, name, email, house_id, password): models.Model.__init__(self) self.name = name self.email = email This works, and ...
Hi, I have a django app running on apache with fastcgi (uses Flup's WSGIServer). This gets setup via dispatch.fcgi, concatenated below: #!/usr/bin/python import sys, os sys.path.insert(0, os.path.realpath('/usr/local/django_src/django')) PROJECT_PATH=os.environ['PROJECT_PATH'] sys.path.insert(0, PROJECT_PATH) os.chdir(PROJECT_PAT...
I have an admin class which uses raw_id_fields. Instead of displaying the number key, I would like to convert that to the __unicode__ for the corresponding foreign key object. I thought a way to do this would be to add a form to the admin class. This form would be one in which the field I want to change is overridden with my own widget...
I'm working with Django. I have a model called Agrument. Arguments have sides and owners. I have a function that returns back the side of the most recent argument of a certain user. like obj.get_current_side(username) I've added this to the actual Argument model like this def get_current_side(self, user): return self.argu...
Hi, I have first_name, last_name & alias (optional) which I need to search for. So, I need a query to give me all the names that have an alias set. Only if I could do: Name.objects.filter(alias!="") So, what is the equivalent to the above? Thanks, VN44CA ...