django

Manage Increasingly complex Django URL views efficiently? (urls.py)

So, I have this Django application and I keep adding new features to provide ever more granular views of the data. To give a quick idea of the problem, here's a subset of urls.py: # Simple enough . . . (r'^$', 'index'), (r'^date/(?P<year>\d{4})$', 'index'), (r'^date/(?P<year>\d{4})-(?P<month>\d{2})$', 'index'), (r'^date/(?P<year>\d{4})...

readonly_field in django

Possible Duplicate: In a django form, How to make a field readonly (or disabled) so that it cannot be edited? I am making a production server in django admin where I have an integerfield available = models.IntegerField(blank=True, help_text="(updated on save)") I was wondering if I could make this a readonly field that wont...

How can I render a Django template that has UTF8 characters in it?

I'm trying to send a django email with UTF-8 characters in the template, specifically: S'il vous plaît I get the error: UnicodeDecodeError: 'utf8' codec can't decode byte 0x94 in position 147: unexpected code byte When trying to encode the special "î" character (that is the character at that position.) Here is my code for genera...

Django Iphone sync

I am writting a django app and Iphone app, I need to keep them in sync. Users can delete, update and create new objects in the web app, and in the iphone app. When they get online with the iphone both app must be in sync. Is there simple way to do this? Thanks, Joaquin ...

Python: how to inherit from two classes?

Hi everybody! First of all I'm a python newbie. I'm playing with Django and I'm trying to extend some classes. Now I'm in this situation: I have a new class customBaseModelAdmin(admin.options.BaseModelAdmin): #override a method of BaseModelAdmin and I want to write another class customModelAdmin(customBaseModelAdmin): that...

Where is meta.local_fields set in django.db.models.base.py ?

I'm getting the error: Exception Value: (1110, "Column 'about' specified twice") As I was reviewing the Django error page, I noticed that the customizations the model User, seem to be appended to the List twice. This seems to be happening here in django/db/model/base.py in base_save(): values = [(f, f.get_db_prep_save(raw and get...

Writing good tests for Django applications

I've never written any tests in my life, but I'd like to start writing tests for my Django projects. I've read some articles about tests and decided to try to write some tests for an extremely simple Django app or a start. The app has two views (a list view, and a detail view) and a model with four fields: class News(models.Model): ...

Model won't validate in Django even with related_name set correctly

I have two abstract models: class Createable(models.Model): createLog = models.ForeignKey(ActionLog, related_name="%(app_label)s_%(class)s_create_action_log") class Meta: abstract = True class Deleteable(models.Model): deleteLog = models.ForeignKey(ActionLog, related_name="%(app_label)s_%(class)s _delete_action_...

Project name inserted automatically in url when using django template url tag

I am applying the 'url' template tag to all links in my current Django project. I have my urls named like so... url(r'^login/$', 'login', name='site_login'), This allows me to access /login at my site's root. I have my template tag defined like so... <a href="{% url site_login %}"> It works fine, except that Django automatically ...

Django ORM's "related data" loading behavior

In LINQ (I come from a C# background), you can manually load data for related tables via the Include("xxx") method from a in ctx.MainTable.Include("SubTable") select a; In the above code, every instance of MainTable is loaded and all the data for MainTable.SubTable is also loaded. If "Include" is not called, every returned MainTable'...

django / haystack / solr simple config - partial field matching issue

I have a simple config of haystack/solr on my django app: from the models.py of this app: class device(models.Model): ... hostname = models.CharField(max_length=45, help_text="The hostname for this device") ... from the search_sites.py of this app: class devIndex(indexes.SearchIndex): '''Haystack class to allow for i...

Django logs location

I am using Django, but I am not sure where to find the logs. ...

django csv import threading

Is it possible to use threading when importing data from csv files to django. ...

loading fixtures for django tests

Hi, I want to use some fixtures in my tests. I have cms_sample app and a fixtures folder inside with cms_sample_data.xml I use the following in my test.py: class Funtionality(TestCase): fixtures = ['cms_sample_data'] I do use TestCase of django.tests and not unittest. But the fixtures are not loaded. What am I missing? Th...

django custom command problem

Having issues getting django custom commands to work. From django documetation, have placed application/ manage.py blog/ __init__.py models.py management/ __init__.py commands/ __init__.py myapp_task.py views.py myapp_task.py content is from django.core.management.base import NoArgsCom...

Problem saving photos in a view using django-imagekit

I'm using this code in one of my views: if request.method == 'POST': vehicle = VehicleForm(request.POST or None) photos = PhotosFormSet(request.POST or None) if vehicle.is_valid(): vehicle.save() photos = PhotosFormSet(request.POST, instance=vehicle) photos.save() return HttpResponse...

Jquery and Django multiple checkbox

Hello all, I am a beginner in jquery so please bear with me. I have a jquery function that allows me to select multiple checkboxes and create a string as follows: function getSelectedVals(){ var tmp =[]; $("input[name='checks']").each(function() { if ($(this).attr('checked')) { checked = ($(this).val()); ...

Get last record in a queryset

How can I retrieve the last record in a certain queryset? ...

jquery autocomplete tagging

Can any one tell me how to use tagging auto-complete in django templates? I have done this in django admin interface but i am confused to how to do it in the template. Thanks in advance ...

Can I use alias field names in django templates?

Hi, I'm new to django and python... I have a model which includes 10 generic fields attrib_00 through attrib_09. I pass these fields as a context to a django template string. I would like to use more meaningful names in the template. The template strings are fetched from another model and I have in mind adding a field containing a co...