django

How to tell Django what's the active window

Out of an "old" tab, i'm opening a new tab in my django-powered web-app. Now, when submitting something in the new tab, it will still load in the old tab, however i want django to do all the stuff in the new tab/window (unfortunately, this also applies to popup-windows (popupwindow = new tab). How can i tell Django in which window it s...

Can the inlineformset_factory create a tabularInline?

I have activity records that have an inline formset showing appointments. I use the inlinefomset_factory. It works but it displays them as an equivalent to a StackedInline you find in InlineModelAdmin. However, I wondered if it can product tabularInline or if anyone has done anything similar? ...

No module named csrf

I have: Python 2.6 Django 1.1.1 I downloaded Django-cms from git://github.com/digi604/django-cms-2.0.git I passed south off/on I stuck on this: After enabling south syncdb returns: Synced: > django.contrib.auth > django.contrib.contenttypes > django.contrib.sessions > django.contrib.admin > django.contrib.sites > publisher > m...

Create or copy table dynamically, using Django db API

Hi, how can I perform smth like CREATE TABLE table_b AS SELECT * FROM table_a using Django db API? ...

Django 1.1.1 chokes on multipart/form-data

Initial story I'm trying to implement file upload using a simple form (I'm pasting stripped version, but all important parts are included): <form method="POST" action="" enctype="multipart/form-data"> <input type="file" name="up_file" size="50"> <input type="hidden" name="cpk" value="{{c.pk}}"> <input type="submit" ...

Django Admin: Path to file uploaded is wrong. Missing "static"?

Hi, I have a simple model and the default admin in django. Everything works as expected and I can upload files. I've read the django docs regarding upload paths. My MEDIA URL and MEDIA ROOT are set and the uploading works. Lets say I login into the default admin, place an order with an uploaded jpg, the I go to edit the order and I see ...

remove default apps from django-admin

good day! by default, in django-admin, there is Users, Groups, ans Sites apps. How can i remove Groups and Sites? i was tried to remove admin.autodiscover() from root urls. Then, when i added smth like admin.site.register(User, UserAdmin) somewhere in my app models i got AlreadyRegistered exception (this is fairly right - models users ...

Ordering of Django models

I set up an ordering='ordering_number' Meta attribute to my Django model, thinking that Django will use it when comparing instances. (ordering_number is an IntegerField in my model.) For example, if I have an instance a with ordering_number = 4 and an instance b with ordering_number = 7, I'd expect that a < b would be True. However, I t...

Data exchange with remote server in Android

Hello! I'm building an application for android which collects user data. Also I'm going to build a website which will use that data where users can have an account and synchronize data with phone and website (I guess it's quite common setup). Site will be using MySQL database, but I want it to be database independent using some kind of...

How to add an Admin class to a model after syncdb?

I added some models in my models.py and I want to add an admin class to use a wysiwyg-editor in text-fields. Well, I know that Django itself doesn't support migrations and I've used South, but it doesn't work either. South doesn't "see" the change. Could...

django admin.site.name in template

Hallo, is there any chance to access the "name" value of the current admin.site object in a admin template? I have 3 different admin.site-objects and want a template tag to generate generic content,depending on the current admin.site.name. thanks in advance ...

is there a way to get django tests + buildout run well integrated with Eclipse/Aptana?

Hi, it's fairly easy to set up Eclipse to run a django project's tests created with django-admin startprojects, we whould just point a Run command to ./manage.py, and supply the necessary arguments. but what can I do if a project is built using buildout? of course, bin/biuldout creates the handy bin/test-1.1 and bin/test-trunk files, ...

save with many-to-many relationship in django problem

I have the following problem in django.. I have in models.py class Proposal(models.Model): #whatever.... credit =models.FloatField(null=True, blank=True) def save(): #here credit is saved based on some calculation (succesfully) class Author(models.Model): #whatever.... balance = models.FloatField(null=True,...

Django memory leak when linking one-to-one fields.

I have a model that contains one-to-one fields to other models. I over rid the save method to automatically assign these one-to-one fields. The problem is whenever I save this model, memory usage goes up by about 450k and is never released. The save method is as follows: class Link(models.model): id = models.CharField(max_length=11, ...

In Django - Model Inheritance - Does it allow you to override a parent model's attribute?

I'm looking to do this: class Place(models.Model): name = models.CharField(max_length=20) rating = models.DecimalField() class LongNamedRestaurant(Place): # Subclassing `Place`. name = models.CharField(max_length=255) # Notice, I'm overriding `Place.name` to give it a longer length. food_type = models.CharField(max_length=25) T...

Any python/django function to check whether a string only contains characters included in my database collation?

hi, As expected, I get an error when entering some characters not included in my database collation: (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='") Is there any function I could use to make sure a string only contains characters existing in my database collation? th...

how to use ForeignKeyRawIdWidget

Hi I want to extend ForeignKeyRawIdWidget so I want to be able to use it without setting raw_id_fields. With the follwoing I don't get an error but I see no effect: # models.py class Product(models.Model): ... class GroupProduct(Product): ... products = models.ManyToManyField(Product, related_name="%(class)s_related") # ...

Extra parameter for Django models

Hello, With Django models, I want to achieve this: class Foo(models.Model): name = models.CharField(max_length=50) #wrapping the save function, including extra tasks def save(self, *args, **kwargs): super(Foo, self).save(*args, **kwargs) if extra_param: ...do task 1 else: ...

Creating a Persistent Data Object In Django

I have a Python-based maximum entropy classifier. It's large, stored as a Pickle, and takes about a minute to unserialize. It's also not thread safe. However, it runs fast and can classify a sample (a simple Python dictionary) in a few milliseconds. I'd like to create a basic Django web app, so users can submit samples to classify in re...

Why is post_save being raised twice during the save of a Django model?

I am attaching a method to the post_save signal of my Django model. This way I can clear some cached items whenever the model is modified. The problem I am having is that the signal is being triggered twice when the model is saved. It doesn't necessarily hurt anything (the code will just gracefully error out) but it can't be right. A ...