django

Is it Me or Are Rails and Django Difficult to Install on Windows?

I tried getting these frameworks working on Windows Vista for a couple of days but to no avail. Every single time I thought I had them working I would get some random error involving the PostgreSQL or MySQL setup, or the paths were screwed up or some other command line error "not recognized as an internal or external command" (or somet...

How can domain aliases be set up using Django?

I am working on creating a website in Django which consists of two parts: the website itself, and the forum. They will both be on separate domains, i.e. example.com and exampleforum.com. How can this be done in Django, when the forum and main site are part of the same instance? ...

how to put comments in django templates

I would like to comment this with a line {% if something.property %} <table> <tr>... {% # this is a comment %} {% if something.property %} <table> <tr>... ...

How do I apply Django model Meta options to models that I did not write?

I want to apply the "ordering" Meta option to the Django model User from django.contrib.auth.models. Normally I would just put the Meta class in the model's definition, but in this case I did not define the model. So where do I put the Meta class to modify the User model? ...

How do i use Django session to read/set cookies?

I am trying to use the Django sessions to read and set my cookies, but when i do the following the program just does not respond! sessionID = request.session["userid"] The program does not pass this point! Any ideas? ...

Removing specific items from Django's cache?

I'm using site wide caching with memcached as the backend. I would like to invalidate pages in the cache when the underlying database object changes. If the page name changes then I would invalidate the whole cache (as it affects navigation on every page. Clumsy but sufficient for my needs. If just the page content changes then I'd li...

Django: How to merge two related querysets in Django 0.96?

Hi all. I would like to merge one querysets related objects with another querysets related objects. Some sample code to explain: ## Models # sample models to illustrate problem class PetShop(models.Model): id = models.AutoField(primary_key=True) shop_name = models.CharField(maxlength=255) cats = models.ManyToManyField(Cat) ...

django templates stripping spaces?

Hi stack overflow, I guess this is a really novice question, still I'm having trouble with django templates and CharField models. So I have a model with a CharField that creates a slug that replaces spaces with underscores. If I create an object Somename Somesurname this creates slug Somename_Somesurname and gets displayed as expected ...

Is there any ways to define 2-tuples in one line?

I'm not expierenced in python. I need to define field 'year' with range restriction. Now i'm using this code, but I think there exists shorten way to do this. YEAR_CHOICE = [] for year in range(2020,1899,-1): YEAR_CHOICE += [(year, year)] year = models.PositiveSmallIntegerField('Year', choices=YEAR_CHOICE, default=0) Is therу any w...

How can you tell if a site has been made with Django?

A company I'm looking at claims to have made the website for an airline and a furniture store using Django, but when I look at the sites, there is no indication what the underlying web technology is. How can you tell? ...

Django GROUP BY strftime date format

I would like to do a SUM on rows in a database and group by date. I am trying to run this SQL query using Django aggregates and annotations: select strftime('%m/%d/%Y', time_stamp) as the_date, sum(numbers_data) from my_model group by the_date; I tried the following: data = My_Model.objects.values("strftime('%m/%d/%Y', ...

Is Google App Engine better than Webfaction for a beginner in Django dev?

I am a beginner in developing websites by Django. I run small discussion websites similar to SO. I have an account at Bluehost which has been a nightmare in developing by Django. I have found that Webfaction and Google App Engine seems to be the best choices for Django. However, I am not sure which one is the best for me. Is Google Ap...

Unable to upload a Django project to Google App Engine

I am trying to test the codes of the project. I run the following code $appcfg.py update masicode/ I get the following error Scanning files on local disk. Initiating update. 2009-04-06 21:58:42,401 ERROR appcfg.py:1235 An unexpected error occurred. Aborting. Traceback (most recent call last): File "/Applications/Coding/Google...

Inserting object with ManyToMany in Django

I have a blog-like application with stories and categories: class Category(models.Model): ... class Story(models.Model): categories = models.ManyToManyField(Category) ... Now I know that when you save a new instance of a model with a many-to-many field, problems come up because the object is not yet in the database. This ...

How can an Ajax callback realize that a user's authenticated session has timed out?

I'm using django and jquery to implement authenticated sessions and Ajax requests. I have authenticated session timeouts to log authenticated users out after a long period of inactivity on my site. Some of the pages on my site have a lot of AJAX calls in them that require the user to be in an authenticated session. When a user leaves ...

Custom actions in Django Admin

Hi all, in my Django app i have a Newsletter model. Now I'd like to be able to send the newsletter (and even resend it) from Django Admin. I could do this with a hook on the Model.save() method but is there another way that is not tied to the Model? Thanks ...

forms.SelectMultiple from models.CommaSeparatedIntegerField

I have a model with field: class Movie(models.Model): genre = models.CommaSeparatedIntegerField(max_length=100, choices=GENRE_CHOICES, blank=True, default=0) lang = models.CommaSeparatedIntegerField(max_length=100, choices=LANG_CHOICES, blank=True, default=0) And I need to get multiple select fields (not checkboxes) from that....

Python/Django pluggin for Dreamweaver

Does a plugin exists for Python/Django into Dreamweaver? Just wondering since Dreamweaver is a great web dev tool. ...

How to handle unicode of an unknown encoding in Django?

I want to save some text to the database using the Django ORM wrappers. The problem is, this text is generated by scraping external websites and many times it seems they are listed with the wrong encoding. I would like to store the raw bytes so I can improve my encoding detection as time goes on without redoing the scrapes. But Django se...

[Django Templates] How to get 'switch-case' statement functionality in Django templates?

Hi, I found a link to have a 'switch' tag in Django templates, but I was wondering if this can be somehow achieved without it. Using only the stuff which comes with Django? Basically is there other way then using multiple 'if' or 'ifequal' statements? Thanks in advance for any tips/suggestions. ...