django

Django: RSS and ATOM feeds Content-Type header?

I followed along this tutorial for django's RSS and ATOM feeds and I got it to work. However the test development server keeps making the browser download the feeds as a file instead of the browser detecting it as an xml document. My experience with HTTP tells me that there is a missing mime type in the Content-Type header. How do I ...

How frequently should Python decorators be used?

I recently started experimenting with Python decorators (and higher-order functions) because it looked like they might make my Django unit tests more concise. e.g., instead of writing: def visit1(): login() do_stuff() logout() I could instead do @handle_login def visit1(): do_stuff() However, after some experimentin...

How do I create an "addons" directory in a Django project?

When building a Django project its common to use many pre-built apps. For example, for tinymce or open-id. It would be nice to keep these separated from project-specific apps. My idea would be to create an "addons" directory/module in the project. It should then be possible to use: from addons.tinymce import models However, tinymce...

djapian based search returns no result

I am trying to implement a djapian based full text search for searching user profiles in my django site. I basically followed the following steps to build the indexes: Updated the model Profile to add the djapian indexer. Ran python manage.py index --rebuild to rebuild the indexes. However when I try to search using the Profile ...

Django official tutorial for the absolute beginner, absolutely failed!

Not that level of failure indeed. I just completed the 4 part tutorial from djangoproject.com, my administration app works fine and my entry point url (/polls/) works well, with the exception that I get this http response: No polls are available. Even if the database has one registry. Entering with the admin app, the entry shows up th...

How to give initial value in modelform

How do i assign initial values to fields inside a ModelForm. eg. class Form1(forms.Form): title=forms.CharField(initial="hello") what will be the equivalent for this using modelForm whose basic syntax is something like: class Form2(djangoforms.ModelForm) class Meta: model=SomeModel fields=('title') What I am tryi...

django-like frameworks?

Hi I've been working with django for some months and find it really helpful, is there alike frameworks for other programming languages such as java or c#? The problem I suffer by using django is finding a server to host the proyect because supporting servers are more expensive and harder to find. From django I find useful: the object-re...

Recursive delete in google app engine

I'm using google app engine with django 1.0.2 (and the django-helper) and wonder how people go about doing recursive delete. Suppose you have a model that's something like this: class Top(BaseModel): pass class Bottom(BaseModel): daddy = db.ReferenceProperty(Top) Now, when I delete an object of type 'Top', I want all the ass...

Django: paginating differently on the first page

Hi At the minute, I'm using Django's object_list to handle pagination. I'm happy to move to the proper Paginator() class if you think I need it after you hear my problem: On the homepage, I want to paginate by 7, but on all other pages I want to paginate by 10. How would I go about doing this? I really can't get my head around it. The...

Django: How to write current users name from every view (django)

Hi! I am writing small social application. One of the features is to write user name in the header of the site. So for example if I am logged in and my name is Oleg (username), then I should see: Hello, Oleg | Click to edit profile Otherwise I should see something like: Hello Please sign-up or join What I want is to show thi...

Changing field type in a Django ModelFormset

In a Django ModelForm, you can change the widget type of a field like so: class EntryForm(ModelForm): entity = forms.CharField() class Meta: model = Entry I can easily create a modelformset from the same model like so: EntryFormSet = modelformset_factory(Entry) But is there a way to include the input field type ch...

Ruby on Rails vs. Django

Possible Duplicate: Rails or Django? (or something else?) These are two web frameworks that are becoming (or have been in many circles) popular. I was wondering what are the advantages and disadvantages of each? Feel free to comment on Ruby and Python pros and cons also. Two disadvantages I am speculative about for RoR is the s...

Right way to create custom pgsql types in django

What is the right way to create custom pgsql types for django application so that each time database is created with syncdb, all custom types are created prior to creating any tables (so that tables can use this type)? I also use django-evolution, but that's not an appropriate solution — it runs after syncdb. I can imagine doing a worka...

Django failing to find apps

I have been working on a django app on my local computer for some time now and i am trying to move it to a mediatemple container and im having a problem when i try to start up django. it gives me this traceback: application failed to start, starting manage.py fastcgi failed:Traceback (most recent call last): File "manage.py", line 11, i...

django: select_related with entry_set

Should entry_set be cached with select_related? My DB is still getting calls even after I use select_related. The pertinent sections class Alias(models.Model): achievements = models.ManyToManyField('Achievement', through='Achiever') def points(self) : points = 0 for a in self.achiever_set.all() : po...

Python, Django, datetime

In my model, I have 2 datetime properties: start_date end_date I would like to count the end date as a one week after the start_date. How can I accomplish this? ...

Django users and authentication from external source

I have a Django app that gets it's data completely from an external source (queried via HTTP). That is, I don't have the option for a local database. Session data is stored in the cache (on my development server I use a SQLite database, so that is no error source). I'm using bleeding edge Django 1.1svn. Enter the problem: I want to use ...

Django: How do I access the request object or any other variable in a form's clean() method?

I am trying to request.user for a form's clean method, but how can I access the request object? Can I modify the clean method to allow variables input? Thanks. ...

Django/Python: How do i transfer a class's attributes to another via a for loop? (Form->Model Instance)

I wish to update a model instance from a form I have. The form is a ModelForm, so it has the same attributes as the model instance, how do I transfer the attributes from the form instance to the model instance instead of doing this: modelinstance.name = form.name . . . . A for loop perhaps? :) Thanks! ...

django - convert a list back to a queryset

I have a handful of records that I would like to sort based on a computed value. Got the answer over here... like so: sorted (Profile.objects.all (), key = lambda p: p.reputation) on a Profile class like this: class Profile(models.Model): ... @property def reputation(self): ... Unfortunately the generic view i...