django

How do I write a Django model with ManyToMany relationsship with self through a Model

I want to have a model with a ManyToMany relationship with itself, I don't know how to write this but I'l try to write some code to illustrate what I want to do. class Person(models.Model): name = models.CharField() occupation = models.CharField() fiends = models.ManyToManyField('self', through = PersonFiends) My Model that ...

ipython showing gibberish when debugging Django with Netbeans

I'm using Netbeans for coding Django. When I insert: import ipdb; ipdb.set_trace() Flow execution gets stopped but it shows gibberish, such as: [1;32m/path/to/file/models.py[0m(344)[0;36macceptBid[1;34m()[0m [1;32m 343 [1;33m [1;32mimport[0m [1;37mipdb[0m[1;33m;[0m [1;37mipdb[0m[1;33m.[0m[1;37mset_trace[0m[1;33m([0m[1;33m)...

Does django grok YML ? django not loading fixtures YML file (yml is not a known serialization)

I have successfully created my first django project. I have two apps in my project foo and foobar. I have created a folder named 'fixtures' in each of the app folders. I have NOT specified a fixtures directory in my settings.yml, so (according to the docs), django should be looking in my {app}/fixtures folder. In the {app}/fixtures fo...

Django : Inline editing of related model using inlineformset

I'm still stuck with the inline Tree-like-eiditing of related models on same page. I've got three models, A, B and C. Class A Class B fb = foreignkey(A) Class C fc = foreignkey(B) In admin.py I'm doing something like AdminA inlines = [inlineB] AdminB inlines = [inlineC] I want that when I edit/add model A, I sh...

Require help in Django 'local variable 'form' referenced before assignment'

Hello, I am having problem in django. I have created a form in my app where I can take details of a client. Now I want to create a form which can allow me to edit a form. However I am having some problems when I go to /index/edit_client/1, I get this error. local variable 'form' referenced before assignment I do not know what the reas...

Question on wget

Can wget be used to get all the files on a server.Suppose if this is the directory structure using Django framework on my site foo.com And if this is the directory structure /web/project1 /web/project2 /web/project3 /web/project4 /web/templates Without knowing the name of d...

Django query performance using FOO_set

Hey, Does Django hit the database again when making queries following relationships backwards using the FOO_set manager? I thought I read somewhere that it does not but I can't find it in the docs anywhere. J ...

Django: Adding extra logic to the login method?

Hi, I've got a django app whose views currently use the @login_required decorator. What's the easiest/best way to add extra logic to the login system? I want to add extra constraints such as that their subscription to the site is still valid. If it has expired I want to direct them to a page that says their subscription has expired and...

Run Django on multiple ports

Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application. I need to accomplish this with the default Django ...

django, python: reload function in shell

Hello, I work in the django IPython-shell, which can be started with manage.py shell. When i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import. Does anyone know how to reload the actual versio...

Summing on only the most recently added record

I'm having a hard time wrapping my head around this Django query. I could probably figure this out with SQL (and maybe I'll have to), but I was wondering if there is a way to do it with Django objects. The model looks something like this (simplified for clarity): class Stat(model.Models): entry_date = models.DateTimeField() qua...

Redirect stdout and stderr to file in Django with wsgi

I'm trying to make django work with wsgi in a shared hosting, so I cannot access server logs, I'm trying to redirect the output to a file in my django.wsgi script, like this: saveout = sys.stdout log_out = open('out.log', 'w') sys.stdout = log_out but this is the error that I have (in the only error log that I can access) [Thu Oc...

Validate/clean a FileField on a non-model form in Django?

I'm ultimately trying to validate a FileField by extension type. But I'm having trouble even getting the clean method for this field to pickup the POSTed value. from django.forms.forms import Form from django.forms.fields import FileField from django.forms.util import ValidationError class TestForm(Form): file = FileField(r...

Mysterious and weird lines after using uni-form

I'm using django-uni-form to display forms. I've included all the css and javascript (notably jquery) in the page. But now I get some weird looking lines. The image below show how it looks: http://i243.photobucket.com/albums/ff176/cwalkrox/uni-form1.jpg You can notice that for username and email address, the lines are aligned with the ...

Django Celery Database for Models on Producer and Worker

I want to develop an application which uses Django as Fronted and Celery to do background stuff. Now, sometimes Celery workers on different machines need database access to my django frontend machine (two different servers). They need to know some realtime stuff and to run the django-app with python manage.py celeryd they need acc...

django: generic views + custom template tags or custom views + generic/normal template tags

This is more of a best-practices question, and given that I'm quite tired it mightn't make much sense. I've been putting together a blog app as a learning experience and as an actual part of a website I am developing. I've designed it like most apps so that you can list blog posts by multiple criteria i.e. /blog/categories/ /blog/au...

CMS for Multilingual Localization and Translation Workflow

Hi, I'm helping build a multilingual website in English, Chinese and French (after in Spanish, Korean and Arabic). I've collected a database of over 2000+ entries. It is essentially a huge product catalog (specifically travel packages) where more or less the info is the same (prices, sizes, numbers, etc.) but the labels change (of cour...

Conditionally required fields across forms?

I've got two forms on one page. If a user selects a certain option on one form, I want to make an option on the other form no longer required. How can I do that? I don't think I can put the logic in the clean method because they're separate forms. ...

Single technology stack vs. multiple technologies for high scale site

Hello, I have recently been come to for advise on an idea of rewriting an existing site due to massive maintenance problems in their old design. Basically, the company is considering a complete rewrite of aprox. 90% of their site which is currently written in PHP using an in-house framework. The company would like to rebuild the backen...

How to update content popularity scoring such as Hacker News algorithm?

I'm using a customized version of Hacker News popularity algorithm for my social site (items with a number of likes and comments). The algorithm works perfectly but I don't know how to update item scorings correctly (I'm storing the score in item model as meta data). Now I'm just updating scores on every new like and comment for items ...