django

Django-Piston - I Can't POST on a model with a ForeignKey

I'm trying to set up piston on my Django project. I ran into a brick wall when I tried to POST (create) a new entry on a model that contains a ForeignKey: location. Here is the exact error I receive: Cannot assign "u'1'": "Fest.location" must be a "Location" instance. In the above example, I tried to send over location=1 in the POST. ...

Fast python tutorial for Django beginners?

Is there a FAST python tutorial for Django beginners? ...

Django Not Loading All CSS Files

I have several CSS files listed in my base.html, and while one of them is loaded, everything else isn't, nor the javascript or images. The following is a portion of base.html: <html> <head> <link href="/media/css/base.css" rel="stylesheet" type="text/css"/> <link href="/media/css/home.css" rel="stylesheet" type="text/cs...

Saving model in Django causes vague socket exception.

I have a simple model that when I try to save, I can see this exception in the PyDev output while debugging my Django app. I've confirmed all fields are being set to their proper values (this is a model with 5 charfield/integer properties). I've stepped through in eclipse to the line that is calling .save(), which is where the exception...

Unable to create superuser on google app engine

I am working on a django project and have used django nonrel to deploy on google app engine. However when I try to create a super user using the command "manage.py remote create superuser", I get the following error, Please let me know if anyone knows the reason for this Username: newuser Traceback (most recent call last): File "C:\SV...

Summary tag for django templates

From time to time I have to write some simple summarized reports using Django. First I tried using Django ORM aggregates and interleaving results, but it can get a bit messy and I loose all the ORM laziness - just doesn't feels right. Lately I wrote a generic iterator class that can group/summarize a dataset. In the view it works like...

How do I save a Django Model from request.POST?

I'm trying to save a new object from a django model using a POST data querydict. This is part of a PISTON handler. I've seen this done in numerous examples, but I just can't get it to work. Here is my code: class FestHandler(BaseHandler): model = Deal def create(self, request): """ Creates a new fest. ...

"fill in the blanks"

I'm trying to make a simple "fill in the blanks" type of exam in django and would like to know what is the best way to design the database. Example: "9 is the sum of 4 and 5, or 3 and 6." During the exam, the above sentence would appear as "__ is the sum of __ and _, or _ and __." Obviously there are unlimited number of answers to t...

Search range of int values using djapian

Hi, I'm using djapian as my search backend, and I'm looking to search for a range of values. For example: query = 'comments:(0..10)' Post.indexer.search(query) would search for Posts with between 0 and 10 comments. I cannot find a way to do this in djapian, though I have found this issue, and patch to implement some kind of date rang...

can't encode single quote (&#39;) using django's render_to_string

hello, i have a problem with django's render_to_string and encoding single quotes. ... = render_to_string('dummy.txt', {'request':request, 'text':text,}, context_instance=RequestContext(request))) why are only these quotes translated to '#39;' and all other special characters not? ...

picking the rows to be in a queryset

I'm building a page where the users can choose which rows to edit. After they select their rows and hit "edit" I'd like to present them with a modelformset_factory showing an editable version of all the rows the user selected. My problem is I believe I need to turn this list of primary keys that I get back into a queryset suitable for u...

Any good audio podcasts for Python and Django?

I listen to Python411 but is there any other great podcasts out there for Python and Django? ...

Multiple ModelManager filter methods

def by_this(self): return super(MyModelManager, self).get_query_set().filter(this=True) def by_that(self): return super(MyModelManager, self).get_query_set().filter(that=True) If i do MyModel.objects.by_this() or by_that() it works. But i want to do: MyModel.objects.by_this().by_that() ...

Parsing a document with BeautifulSoup while not-parsing the contents of <code> tags

I'm writing a blog app with Django. I want to enable comment writers to use some tags (like <strong>, a, et cetera) but disable all others. In addition, I want to let them put code in <code> tags, and have pygments parse them. For example, someone might write this comment: I like this article, but the third code example <em>could have...

Error on display static content

I have a template with a static image. Each second call of this page the image doesn't display and I get next error in the console: Development server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [24/Oct/2010 11:25:36] "GET /index/ HTTP/1.1" 200 20058 [24/Oct/2010 11:25:36] "GET /images/logo.png HTTP/1.1" 500 65...

AttributeError: object has no attribute 'rindex' when using RSS Framework

Hi all, I'm following the documentation at http://docs.djangoproject.com/en/1.2/ref/contrib/syndication/ quite closely, but I keep getting AttributeError: object has no attribute 'rindex' when implementing the following. urls.py: from django.conf.urls.defaults import * from feedcreator.feeds import FeedPosts urlpatterns += patterns('...

How to test whether a Django FileField is blank?

What is the right way to test whether a Django FileField is blank, i.e., when no file has been uploaded? It looks like the name attribute is u'' when the field is blank, but I don't know whether that is reliable. ...

django admin lost password recovery

I have some data in my dev database (not yest exported to fixtures), so I dont want to run syncdb. However, I have lost my pwd for the admin section of my demo django website (I have not worked on it for a little while) Is the password stored somewhere in the config/settings etc? How can I recover the admin pwd? ...

calling function in django manager object from template

i am using django ratings application into this fields.py module,i added new function to RatingManager class which is get_bayesian see below http://github.com/dcramer/django-ratings/blob/master/djangoratings/fields.py def get_real_rating(self): """get_rating() Returns the unmodified average rating.""" if not (self.votes a...

python, django: copy image

I created this function, to copy an image from a django-model to another django-model. The image has to be saved redundantly: def __copy_file__(from_object,to_object,field): attr = field.attname try: newpath = getattr(from_object,attr).path dot_at = newpath.rfind(".") while os.path.exists(newpath): ...