django

how to separate out the many-to-many add field in django admin

Hi all, So i have an Article and a Comment model. Comment have a foreign key pointing to Article. As well Comment in admin.py is admin.StackedInline. Currently, in the admin view of Article, i have an extra column for the latest 3 comments displayed (using a custom function). I would like to have a behavior that when the user clicks on ...

Python/django inherit from 2 classes

In my django project I have 2 variations of users. One subclasses User class from django.auth and second uses almost the same fields but is not a real user (so it doesn't inherit from User). Is there a way to create a FieldUser class (that stores fields only) and for RealUser subclass both FieldUser and User, but for FakeUser subclass on...

Django query to get next previous item by date in category...

Hello. First time poster to Stack Overflow... I suspect my answer lies in this solution: http://stackoverflow.com/questions/2074514/django-query-that-get-most-recent-objects-from-different-categories but I am having trouble 'getting' Django's annotate() functionality. I've gotten this far: previous = Item.objects.filter(date_added...

Django form is throwing error: "takes exactly 1 argument (0 given)"

I'm working on a basic event form created from a model, but I keep getting the following error message: TypeError at /addlaundry/ addlaundry() takes exactly 1 argument (0 given) I think it's because I'm not passing the argument through on views, but I can't find documented anywhere how to do this right, at least not written in a way I...

Django: Get list of model fields?

I've defined a User class which (ultimately) inherits from models.Model. I want to get a list of all the fields defined for this model. For example, phone_number = CharField(max_length=20). Basically, I want to retrieve anything that inherits from the Field class. I thought I'd be able to retrieve these by taking advantage of inspect.ge...

Django template variable not being rendered into JavaScript

I have the following Javascript between tags in a template: YAHOO.util.Event.addListener(window, "load", function() { YAHOO.example.Taco = function() { var myColumnDefs = [ {% for field in included_fields %} {key:"{{ field }}", sortable:true, resizeable:true}, {% endfor %} ]; var myDataSource = n...

Where in the source is the Model Field -> Form Field specified?

ala this page http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#field-types Basically, I have a bunch of model field objects, and I want to find the corresponding form field that django uses by default. ...

How do I install CKEditor with Django-WYSIWYG

I am trying to install the CKEditor for use with Django-WYSIWYG. This is proving to be oddly difficult. As mentioned on the site for Django-WYSIWYG, it is possible to "install" CKEditor by dropping the distribution file in the MEDIA_URL folder on one's system. In addition, you've got to set a variable in settings, which determines Djan...

Django url.py without method names

In my Django project, my url.py module looks something like this: urlpatterns = patterns('', (r'^$', 'web.views.home.index'), (r'^home/index', 'web.views.home.index'), (r'^home/login', 'web.views.home.login'), (r'^home/logout', 'web.views.home.logout'), (r'^home/register', 'web.views.home.register'), ) Is there a w...

Creating multiple sites with django

Hi all, I have to create a project in django where the admin can create the sites dynamically and assign the administrators for the same, which would manage that particular site. Can someone please suggest with some hint on how it can be done? Thanks in advance. ...

displaying ajax response in textarea as soon as page is loaded

hi, I have a continous ajax request asking for some data that is to be displayed in textarea. Now my problem, how do I display the data as soon as page is loaded. My template code is as follows: <html> <head> <script type="text/javascript" src="/jquerycall/"></script> <script type="text/javascript"> $(document).ready(fun...

Stack Overflow's User authentication style

I have to say, stack overflow's user authentication system is probably the best out there. I truly admire using cookies to store anonymous's identity and was planning to do something like that for my sites too (since it is so convenient). I am fluent in django and python, is that enough to build an authentication system which is based ...

Django Admin - Displaying Intermediary Fields for M2M Models

Hi, We have a Django app which contains a list of newspaper articles. Each article has a m2m relationship with both a "spokesperson", as well as a "firm" (company mentioned in the article). At the moment, the Add Article page for creating new Articles is quite close to what we want - it's just the stock Django Admin, and we're using fi...

Best way to get xml-rpc and django working together

I have worked with django for a while but I am new to xml-rpc. I have two django servers running and 1st needs to call some functions from some modules of 2nd. I find xml-rpc easiest way to do so but don't want to run a separate server for this only. What options do I have ? Can I run django's web-server and xml-rpc server with a single ...

Django singals file, cannot import model names

I have such file order: project/ app/ models.py signals.py I am keeping signals inside signals.py as it should be. and at the top of the signals.py file, I include myapp models as I do queries in these signals with from myproject.myapp.models import Foo However it doesnt seem to find it, as I run the server or ...

How do i test django ratings in my application?

Guys, I have installed django-ratings application in my django project. Am wondering how best can i test my app voting functionality because django ratings is only allowing me to vote once for the same user, object and Ip address. Is there a way i can disable this checks so that i can just insert votes, test my application and when ...

Django, creating user with add user permission

Hi All, I have gone through a strange behavior while creating a user, using Django admin interface. I have to create a user which can add other users, but for that Django requires two permissions i.e. add user and change user. But when I gave user the change permission, its even able to change the superuser of the site. What I want is...

django store incremental numeric values in a table?

i want to make a rank application, that will calculate the rank of each course uploaded on a platform. Is it a good approach to have stored in a table values like number of downloads, and number of views, like that? class Courserate(models.Model): course = models.ForeignKey(Courses) downloads = models.IntegerField(editable = F...

django model subclassing: get the subclass by querying the superclass

The following code is given: class BaseMedium(models.Model): title = models.CharField(max_length=40) slug = models.SlugField() class A(BaseMedium): url = models.URLField() class B(BaseMedium): email = models.EmailField() I now want to query every BaseMedium. b = BaseMedium.objects.all() How do I print every infor...

django upload text file not working

I am trying to upload text files to a specified location, but the file is uploading empty, in the root(not in the location i specified). in models: course = models.FileField(help_text=('Upload a course (max %s kilobytes)' %settings.MAX_COURSE_UPLOAD_SIZE),upload_to='cfolder/',blank=True) in forms: def handle_uploaded_file(f): d...