django

Deploy django under snow leopard server?

Any tutorials, how-tos or sth. about deploying django apps under snow leopard server? What do I need? Thanks! ...

Django Dynamic Forms

I am using James Bennetts code to create a dynamic form. I have everything working but want to save the data to a database. Has anyone got any code which does this or could show me what the best way to do this would be e.g. how the model should be set up etc? ...

django admin permissions - can edit user but can't edit his permissons - how to do it?

I gave the editors such permissions: auth | user | can add/change user - ON auth | permissions | can add/change permissions - OFF Still, when editing, they can change their permissions (and allow themselves actions they shouldn't do). I've found a ticket from 2yrs ago: http://code.djangoproject.com/ticket/6519 and it still works this...

viewing translations in django templates (e.g - making it work)

Hello - I'm trying to figure out the django translation system, so I wrote a little test app. I created the translation files and compiled them (*.po and *.mo), and now I'm trying to render a template in a different language. I change the LANGUAGE_CODE in my settings.py to the other language code, but the template still renders in Englis...

The best way to join two dissimilar mySQL tables -- planning for django from python.

Hi all, table a (t_a): id name last first email state country 0 sklass klass steve [email protected] in uk 1 jabid abid john [email protected] ny us 2 jcolle colle john [email protected] wi us table b (t_b): id sn given nick email l c 0 steven klass ...

Best Practice to get related values in django without DoesNotExist error

If I have two models in Django: class Blog(models.Model): author = models.CharField() class Post(models.Model): blog = models.ForeignKey(Blog) And I want to get all posts for a given blog: Blog.objects.get(author='John').post_set If there is a Blog with author='John' but not posts, a DoesNotExist exception is raised. What...

How to organize a webapp?

I'm starting my first webapp, and I'm not sure how things typically are done. I'm using Django and Apache: How do you manage a source control repository? Do you check out to a separate folder, and then have a build script that copies files over? What exactly should be added to the repository? In other words, how do you make sure that y...

Django creating a form field that's read only using widgets

My form field looks something like the following: class FooForm(ModelForm): somefield = models.CharField( widget=forms.TextInput(attrs={'readonly':'readonly'}) ) class Meta: model = Foo Geting an error like the following with the code above: init() got an unexpected keyword argument 'widget' I thought this is a...

In python how can I check to see if an object has a value?

Base Account class BaseAccount(models.Model): user = models.ForeignKey(User, unique=True) def __unicode__(self): """ Return the unicode representation of this customer, which is the user's full name, if set, otherwise, the user's username """ fn = self.user.get_full_name() if fn: return fn return sel...

How to write better template tags in django...

I've seen how I can write template tags that set a context variable based on a template like this {% my_template_tag 'blah' as my_context_variable %} But I'd like to be able to do this: given that both group and user are set in the context in the view {% is_in_group group user as is_member %} {% if is_member %} #.... do stuff ....

Determine complete Django url configuration

Is there a way to get the complete django url configuration? For example Django's debugging 404 page does not show included url configs, so this is not the complete configuration. Answer: Thanks to Alasdair, here is an example script: import urls def show_urls(urllist, depth=0): for entry in urllist: print " " * depth,...

Using an RPC like Protocol Buffers as a backend to Django, instead of MySQL or SQLite

The clever folks behind the app-engine-patch project have essentially enabled all the fun stuff of Django, including the admin, but without using Django's ORM. From their website: The most important change is that you have to use Google's Model class because the development model is too different from Django (at least with Django's ...

Update model object with new dynamicaly created field?

I have Queryset: queryset = Status.objects.all()[:10] Model Status hasn't got field commentAmount so I would add it to every object in Queryset: for s in queryset: s.commentAmount = s.getCommentAmount() All is fine, print s.commentAmount shows good results, but after: response = HttpResponse() response['Content-Type'] = "text/j...

How can I programmatically obtain the max_length of a Django model field?

Say I have a Django class something like this: class Person(models.Model): name = models.CharField(max_length=50) # ... How can I programatically obtain the max_length value for the name field? ...

Review my Django Model - Need lots of suggestions.

Hi all, I am pulling a variety of information sources to build up a profile of a person. Once I do this I want to the flexibility to look at a person in a different ways. I don't have a lot of expierience in django so I would like a critique (be gentle) of my model. Admittedly even as I coded this I'm thinking redundancy (against DRY...

reusable application for django site wide announcements that displays a message only once per user.

I want to show various messages to registered users only once in my django application. I found django-announcements which seemed to do what I want - but I found in testing it marks messages as read by using a session variable, which disappears if the user logs out. This means a message is shown again to a user if they dismiss it when l...

Django: ManyToMany Inline Admin view error

Here are the model definitions: class ItemBrand(models.Model): name = models.CharField(max_length = 30, unique = True) def __unicode__(self): return self.name class WantedItem(models.Model): name = models.CharField(max_length = 120) description = models.TextField() created = models.DateTimeField(auto_now = False, auto_now_add = Tr...

How to find the total number of SQL queries made by a django application?

Is there a way to find out how many SQL queries made by django app. when I try to load a page? What I like to do as I browse from page to page.. is to record the following in a text file... or see it in stdout. page url total queries total query execution time is there such tool/script? Cheers ...

How can i use ManyToManyRawIdWidget outside admin?

Im new to django and I would like to know how could i use the ManytoManyRawId widget outside admin. I've tried different ways but still don't work. Help would be really much appreciated. ...

Is there any way to make Django's USStateField() to not have a pre-selected value?

I use USStateField() from Django's localflavor in one of my models: class MyClass(models.Model): state = USStateField(blank=True) Then I made a form from that class: class MyClassForm(forms.ModelForm): class Meta: model = MyClass When I display the form, the field "State" is a drop-down box with "Alabama" pre-sel...