django

What is the best / proper idiom in django for modifying a field during a .save() where you need to old value?

Hi, say I've got: class LogModel(models.Model): message = models.CharField(max_length=512) class Assignment(models.Model): someperson = models.ForeignKey(SomeOtherModel) def save(self, *args, **kwargs): super(Assignment, self).save() old_person = #????? LogModel(message="%s is no longer assigned to ...

How can display a FloatField in a Django admin column rounded to the nearest integer, without using a custom list_display?

It would be easy with a custom list_display, but that would cause me to lose the sorting ability according to that column. ...

Django - how to write users and profiles handling in best way?

Hey, I am writing simple site that requires users and profiles to be handled. The first initial thought is to use django's build in user handling, but then the user model is too narrow and does not contain fields that I need. The documentation mentions user profiles, but user profiles section has been removed from djangobook covering dj...

Django limit access by group only

I only you can limit what a user can do via the user permissions in admin.. But is there a way to limit them in admin via what group you add them to? I want to allow a certain group to do everything in that model if they belong to a certain group thanks! ...

django link format words joined with hypens

href="http://www.torontolife.com/daily/daily-dish/restauranto/2010/03/10/best-new-restaurants-2010-james-chatto-names-five-honourable-mentions/">Best new restaurants 2010: honourable mentions does django have built in mechanism to format links above i mean words joined with hypens how can i achieve this ? ...

looking for django app for collaborative Wiki

I've been trying to find a django wiki app, which has the following - 1.) WYSIWYG 2.) Attach files 3.) Revisions I see moinmoin, but before going all in, wanted to see what you all have used. ...

Is it approproate it use django signals withing the same app

Trying to add email notification to my app in the cleanest way possible. When certain fields of a model change, app should send a notification to a user. Here's my old solution: from django.contrib.auth import User class MyModel(models.Model): user = models.ForeignKey(User) field_a = models.CharField() field_b = models.Ch...

Accessing data entered into multiple Django forms and generating them onto a new URL

I have a projects page where users can start up new projects. Each project has two forms. The two forms are: class ProjectForm(forms.Form): Title = forms.CharField(max_length=100, widget=_hfill) class SsdForm(forms.Form): Status = forms.ModelChoiceField(queryset=P.ProjectStatus.objects.all()) With their respective models as follows:...

How to host 50 domains/sites with common Django code base

I have 50 different websites that use the same layout and code base, but mostly non-overlapping data (regional support sites, not link farm). Is there a way to have a single installation of the code and run all 50 at the same time? When I have a bug to fix (or deploy new feature), I want to deploy ONE time + 1 restart and be done with ...

How do I perform a batch insert in Django?

In mysql, you can insert multiple rows to a table in one query for n > 0: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9), ..., (n-2, n-1, n); Is there a way to achieve the above with Django queryset methods? Here's an example: values = [(1, 2, 3), (4, 5, 6), ...] for value in values: SomeModel.objects.create(first=v...

Why is Django sending the wrong email template?

I can't find the bug in this code. I've tried isolating the problem, but it works when I copy the relevant code into a separate file. The problem must be with the surrounding code, but I don't see how it's even relevant. Here's everything: The problem is with the "Activate Your PROJECT Account" email. It sends me an email with something...

Cannot get MEDIA_URL from Django widget's template

Hi folks, I am a new Djangoer, and figuring out how to build custom widget, my problem is cannot get the MEDIA_URL in my widget's template, while the form use MySelectWidget able to get the MEDIA_URL itself. # #plus_sign.html # <a href="" class="" id="id_{{ field }}"> <img src="{{ MEDIA_URL }}images/plus_sign.gif" width="10" height...

ContentType Issue -- Human is an idiot - Can't figure out how to tie the original model to a ContentType abstracted 'Favorite' model

Originally started here: http://stackoverflow.com/questions/2650181/django-in-query-as-a-string-result-invalid-literal-for-int-with-base-10 I have a number of apps within my site, currently working with a simple "Blog" app. I have developed a 'Favorite' app, easily enough, that leverages the ContentType framework in Django to allow me ...

Get and set data on Google App Engine

How can I store some data on Google App Engine? I'm using Django. ...

remote_api in google app engine is the best way to store data ??

i don't know what the remote_api will do thanks ...

How to combine sphinxquerysets in djang-sphinx

querysets from django can be combined with a pipe like so: q1 = Articles.objects.filter(name="goats") q2 = Articles.objects.filter(name='cows') q1 = q1|q2. Is there a way to do this for sphinxquerysets? So far, I'm striking out. ...

Django admin: Add a "remove file" field for Image- or FileFields

I was hunting around the Internet for a way to easily allow users to blank out imagefield/filefields they have set in the admin. I found this: http://www.djangosnippets.org/snippets/894/. What was really interesting to me here was the code posted in the comment by rfugger: remove_the_file = forms.BooleanField(required=False) def save...

Django custom SQL returning single row of results when query returns 2?

I have a custom SQL call that is returning different results to the template than I get when I run the same query against the database directly, 1 row vs 2 Query - copied from Django Debug Toolbar: SELECT ((Sum(new_recruit_interviews) / Sum(opportunities_offered)) * 100) as avg_recruit, ((Sum(inspections) / Sum(presentations)) * 100) ...

Where can i find good practice python problems with solutions?

Where can i find good practice python problems with solutions? I'm looking for detailed practice problems that are designed with a coding purpose in mind. ...

how to get the filed mapName 's value on a form.. uding django

my form is class MapForm(forms.ModelForm): class Meta: model = Map fields = ('mapName', 'kmlStr') and the view is : map_form = MapForm(request.POST or None) if map_form.is_valid(): map = map_form.save(commit=False) map.mapName=map_form.mapName#is this code right ? how to get the mapName 's value , us ...