django

Django syndication: How do I avoid description escaping?

Hello. I'm trying to make a webcomic RSS feed with Django, but I can't put an image in the description field, because the html code gets escaped, even if it's in an {% autoescape off %} block. Here is my description template: {% autoescape off %} <img src="{{obj.img.url}}"/> {% endautoescape %} And this is the result: &lt;img src="h...

How do I use Django's template extends variable?

The django template doc mentions the following for extending templates: {% extends variable %} Where do I define the variable? Is it from the views.py? ...

Django admin, error deleting user

I'm trying to delete a user using Django Admin, but I get this error: TypeError: coercing to Unicode: need string or buffer, User found What could cause this error? The complete error: TypeError at /admin/auth/user/ coercing to Unicode: need string or buffer, User found Request Method: POST Request URL: http://www.domain.com/admi...

save() method deletes existing record when using unique_together in Django model

I am using the following class in models.py: class Player(models.Model): id = models.AutoField(primary_key=True) sport = models.CharField(max_length=3, choices=SPORT_CHOICES) yid = models.IntegerField() first = models.CharField(max_length=30) last = models.CharField(max_length=30) team = models.CharField(max_leng...

import csv file into mysql database using django web application

hi everyone!i try to upload a csv file into my web application and store it into mysql database but failed.Please can anyone help me? my user.py script: def import_contact(request): if request.method == 'POST': form = UploadContactForm(request.POST, request.FILES) if form.is_valid(): csvfile = request.FILES['file'] print csvfile ...

Using UTM with geodjango

I'm looking into using the UTM coordinate system with geodjango. And I can't figure out how to get the data in properly. I've been browsing the documentation and it seems that the "GEOSGeometry(geo_input, srid=None)" or "OGRGeometry" could be used with an EWKT, but I can't figure out how to format the data. It looks like the UTM SRID i...

Django models - Does django cache former queries?

Below I call the same methods in author and w5 model objects. But one of them raises an error: >>> author = models.Author('ali') >>> author.article_set.count() --------------------------------------------- ValueError: invalid literal for int() with base 10: 'ali' >>> w5 = models.Author(name='w5') >>> w5.article_set.count() 0 Actually...

django re-usable app and django project structure

Hi, I am wondering if this is a good practice. I usually have re-usable django-apps and python lib's under "lib" directory and it works good. Then I have "templates" directory directly under project root and I copy the default app templates from lib/django-app/templates to my project "templates" directory and modify my layout changes. ...

Django: AuditTrail & Lazy Relations

I've been trying to modify the AuditTrail code so that it does not copy ForeignKey fields, but rather copies the related field (ie I don't want a foreign key on my database table for the audit model). I've written a copy_field function that looks like so: def copy_field(field): while(isinstance(field, models.OneToOneField, models.F...

django template system, calling a function inside a model

hello, I want to call a function from my model at a template such as: class ChannelStatus(models.Model): .............................. .............................. def get_related_deltas(self,epk): mystring = "" if not self.get_error_code_delta(epk): return mystring else: for i in self.get_listof_ou...

Method Output in Admin Detail-View

Is there an easy way of displaying method output in Djangos admin detail view? For the list view we have the list_display field, however i cannot find anything similar for the detail view. Of course, editing the template would be a way but isnt there something easier? ...

Why is my jQuery.ajax response empty with Django

I'm trying to return a JSON response from a Django view call via an ajax call like below: var tab = 'test'; var response = $.ajax({ url: "/" + tab + "/" }).responseText; alert(response); Here is my Django view: if request.is_ajax() == True: req = {} req['html'] = '<b>This is a test</b>' response = simplejson.dumps(re...

Django Dynamic Drop-down List from Database

Hi...I wanted to develop a Django app and one of the functionalities I'd like to have is dynamic drop-down lists...specifically for vehicle makes and models...selecting a specific make will update the models list with only the models that fall under that make....I know this is possible in javascript or jQuery (this would be my best choic...

How to implement Synchronization Tag in django

We are making a synchronization between one master database and many slave databases over tight link (7kb). To minimize amount of data send we tag each record that was sent successfully. To do so we created following models: class SynchronizationTag(models.Model): STATUSES = ((0, "Invalid"), (1, "Pending"), ...

Problems updating user profiles.

Working out editing profiles and ran into a little trouble! The following piece of code succesfully updates the mug_shot column in the user profile, but also erases all the other column data for that particular record. It's weird because Django is supposed to automatically distinguish between updates/saves. What's weirder is that everywh...

django model design questions

I need to store various info about some movies, books, games, and maybe other media. Starting from publisher to disc count in DVD-box. At first i thought about abstract Item model, with children Book, Movie, Game. But it's all hard-coded and not very scalable, i think. What if i would need to add some new item type? Then I've read abou...

Django HttpResponseRedirect reverse function in tutorial

Can someone please explain what is going on here with the Django Tutorial Part 4 Specifically, how the map function is working? I understand that URLs shouldn't be hardcoded in the view functions. return HttpResponseRedirect(reverse('mysite.polls.views.results', args=(p.id,))) ...

How can I MODIFY django to create "view" permission?

I've recently started using django to administer a large existing application that was grown organically over the years using twisted.web. I started experimenting with django and it's automatic admin interface and I've been very pleased with the results. One thing that seems to be missing for my purposes is the ability to give users re...

Django pathing to javascript doesn't work

I've been trying all sorts of things and can't figure this out! For some reason on the Django development server the paths to the javascript just don't work. Directory structure is site | appName static templates | | | views.py javascript appName | ...

Django, ModelChoiceField() and initial value

Hi guys, im using something like this: field1 = forms.ModelChoiceField(queryset=...) Now how ill show selected x value from the database? thanks ...