django

One blog for each Django user with the "blog role"

Hi, What approach is the best way to make content-types restricted to a user in Django, lets say that i want all users with the user-role "blogger" to have its own blog. Ive createt a weblog app, but how do i restrict it so that the user logged inn can only post in his "own" blog, and how do I make views that shows only a users blog? ...

How to get a list of all users with a specific permission group in Django

Hi, I want to get a list of all Django auth user with a specific permission group, something like this: user_dict = { 'queryset': User.objects.filter(permisson='blogger') } But I cant seem to find out how to do this. How are the permissions groups saved in the user model? ...

How do I save a NamedTemporaryFile into a model FileField in Django?

I created a NamedTemporaryFile, added some content in it and now I want to save it into a model FileField. The problem is that I get a SuspiciousOperation because the tmp directory is not within the FileSystemStorage directory. What's the proper way to do this? ...

Is it possible to use Django to include CSS (here's the tricky part) from a JS file?

As far as I know, there's no way to use {% include %} within a dynamic JS file to include styles. But I don't want to have to make another call to the server to download styles. Perhaps it would be possible by taking a stylesheet and injecting it into the head element of the document...has anyone does this before? ...

Django: How can I use my model classes to interact with my database from outside Django?

I'd like to write a script that interacts with my DB using a Django app's model. However, I would like to be able to run this script from the command line or via cron. What all do I need to import to allow this? ...

What is the best IDE setup for web development?

I am starting a little side project which consists of building a small-medium sized, django-based, website. However, last time I was actually in the business of websites, was a few good years ago. So while still technologically capable, I'm still rusted on the tools/IDE part of websites. I am looking for an IDE which can support the fo...

Django objects.filter, how "expensive" would this be?

I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database server. soknad_lis...

Code refactoring help - how to reorganize validations

We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram: user input <=> model object <=> database storage validations are needed with request coming from user input but NOT when coming from database lookup hits ...

How do you manage your Django applications?

Hi, I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications. Let's take a kind of SO as an example. Which applications would you use? I'd say there should be the applications "users" and ...

Django model naming convention

What is the preferred naming convention for Django model classes? ...

How to have a link in label of a form field

I want to have a checkbox for terms and conditions, label of which should contain a link to a page with, well, terms and conditions. The following field will have the label with the tags escaped. BooleanField(label="I agree to <a href='terms-conditions.html'>terms&conditions</a>") ...

What are the steps to make a ModelForm work with a ManyToMany relationship with an intermediary model in Django?

I have a Client and Groupe Model. A Client can be part of multiple groups. Clients that are part of a group can use its group's free rental rate at anytime but only once. That is where the intermediary model (ClientGroupe) comes in with that extra data. For now, when I try to save the m2m data, it just dies and says I should use the C...

printing a list of persons with more than one home, each home with more than one phone number...

I have a class Person which can have several Homes, each one with one or many Phone numbers. I have defined the classes, but now i am trying to create a view wich list every person, with all its homes and all the phone numbers for each home address... something like: john smith 123 fake str 305-99-8877 305-99-8876 321 oak road 44...

How can i create a lookup in Django?

I have a Question model & Form, one of the fields in this model is userid=ForeignKey(User), this Works perfectly well on the Question Model, am able to pick the user from a drop down. But kind a tricky when i want to list the question from the model, which is the best way to lookup the user name from the Users table? becouse at this po...

Django: How do I use the built in password reset/change views with my own templates.

For example I can point the url '^/accounts/password/reset/$' to django.contrib.auth.views.password_reset with my template filename in the context but I think need to send more context details. I need to know exactly what context to add for each of the password reset & change views. Thanks. ...

Unicode appnames in Django

Hi, I live in Norway, and when i make Django apps i would like to be able to name my apps with characters like "æøå", these characters work fine in unicode, but when i try to use these characters in app names, or in fields display text i get an error. Even better, i would like to name my apps by the english convention, but have somethi...

How to process two forms in one view?

I have two completely different forms in one template. How to process them in one view? How can I distinguish which of the forms was submitted? How can I use prefix to acomplish that? Or maybe it's better to write separate views? regards chriss ...

How to handle JSON encoded strings using jQuery

I am currently using Django to construct JSON encoded objects which a retrieved using jQuery.getJSON(). The standard simplejson encoder encodes strings according to the JSON "standard", i.e. any string containing a '/' is translated to '\/'. Therefore if one of my parameters is a url, e.g. http://example.com/image.jpg it is passed to t...

What values to use for FastCGI maxrequests, maxspare, minspare, maxchildren?

I'm running a Django app using FastCGI and lighttpd. Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren? These options are not too well documented, but seem quite important. Don't just tell me what they do; I want to understand what implications they have and...

Django + FastCGI - randomly raising OperationalError

I'm running a Django application. Had it under Apache + mod_python before, and it was all OK. Switched to Lighttpd + FastCGI. Now I randomly get the following exception (neither the place nor the time where it appears seem to be predictable). Since it's random, and it appears only after switching to FastCGI, I assume it has something to ...