django

Django datetime task friendly format

How would you format django datetime, so it produces results in task friendly format 23 sec remaining 2 hour 14 minutes remaining 4 days ...

Is it okay that database credentials are stored in plain text?

By default, the Django database host/user/password are stored in the project settings.py file in plain text. I can't seem to think of a better way at the moment, but this seems to be against best practices for password storage. Granted, if an attacker has access to the settings file, then all is probably already lost. Even if the the fi...

How can I sort my Django model using complex data from a second model?

I have 3 django models (simplified for this example): class Fighter (models.Model): name = models.CharField(max_length=100) weight_class = models.ForeignKey(WeightClass, related_name="fighter_weight_class") class Bout (models.Model): fighter_1 = models.ForeignKey(Fighter, related_name="bout_fighter_1") fighter_2 = model...

Is it possible to run linux on hand-held tablets?

I want to run a django app on a hand-held device. It'll need to run Python (obviously) and will write its data to an SQLite database. Are there any tablets available that will let me do this? Specifically, if I bought an Android tablet, would I have to/be able to install linux instead, or would I be able to run it under Android? ...

How can I make a verbose template tag in Django?

I have the following inclusion tag: @register.inclusion_tag('bouts/fighter/_fighter_bout_list.html') def fighter_bout_list(list, header, fighter, has, empty): return { 'list' : list, 'header': header, 'fighter': fighter, 'has' : has, 'empty' : empty, } To use it, I ca...

How can I create sophisticated Django Model Validation for Django Admin?

I have the following model in Django: class Bout (models.Model): fighter_1 = models.ForeignKey(Fighter, related_name="bout_fighter_1") fighter_2 = models.ForeignKey(Fighter, related_name="bout_fighter_2") winner = models.ForeignKey(Fighter, related_name="bout_winner", blank=True, null=True, help_text='Leave blank fo...

Is there a template hiearachy in Wordpress similar to Django?

I'm a veteran Django programmer and a newbie in WordPress. In Django, we have the concept of templating such that I can create File1 which contains some html blocks that can be overriden by child File2. We are using {block block1} syntax in Django. This makes re-use in django very easy. In PHP (WordPress) do we have the same concept? I w...

django standalone script import error

Hi, I have a working django site and I'm trying to run a standalone script over its data. I am following this article, but can't get it to work. I have tried two approaches: 1) import sys, os sys.path.append(os.path.abspath('..')) os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' from mysite.main.models import Image #from main...

Django Admin: Allow email as a username?

I've recently inherited a django project and I'm facing a serious amount of bugs/issues and ...quirks that need to be fixed. As I'm coming from a php background (don't ask), I'm having a ...challenging time. In terms of the Django admin, It will not accept any email address as a username. However, IN our front-end - the previous develop...

Django site 504 time out on nginx

We have django 1.1.1 website, that works fine on development server (python manage.py runserver). But when we use nginx + wsgi, ngnix is timed out and return "504 Gateway is time out". error.log is empty. So, probably it is environment issue but I don't know where to start because it was working fine and now its not and I have no error...

How to import datetime module in Django?

I've learned some basic in Django but I stucked in this tutorial: http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list Error found when was_published_today added: global name 'datetime' is not defined Some search results suggest me to import datetime module, but I have no idea how to do it. from d...

Django and FeinCMS: A way to use the Media Library in other normal models?

I'm using Django and FeinCMS on a project. I'm currently using FeinCMS for all the pages on the site. But I also have another separate model that handles very simple stock for the site too. This stock model has the usual fields (name, description, etc) but I also want it to have photos. Because FeinCMS has a media library already, I wou...

Django annotate groupings by month

Hello, I have a very basic model: class Link(models.Model): title = models.CharField(max_length=250, null=False) user = models.ForeignKey(User) url = models.CharField(max_length=250, blank=True, null=True) link_count = models.IntegerField(default=0) pub_date = models.DateField(auto_now_add=True) updated = models...

In Django, how do I allow print statements to work with Apache WSGI?

"print" only works in development server. But what if I want it to work in Apache? Just in case I forget to comment it out...I want to be able to go smoothly without causing errors. (Just print to nothing) ...

What is the Django way to do this?

class Article(models.Model): def user_may_see_full_version(self, user): # do something very sophisticated with the user return [True/False whatever] now i want to create a template like this: {% for article in articles %} {% if article.user_may_see_full_version request.user %}{{ article }}{% else %}{{article.ti...

Django CMS functionality

Hi there, for some days now, I'm considering whether I should use a CMS-like Django-App for a new web-portal I'm ordered to build. Most parts of the portal will be purely model-driven (like News, small ads, directories etc), but there are several static pages that shall be maintained by editors. I tested out different systems, like Dja...

Can't get mod_wsgi and Apache with Django to work

This is the error I get in my Apache error log: [Sun Aug 22 16:52:06 2010] [error] [client 127.0.0.1] ImportError: No module named settings This is my .wsgi file, per this blog post: import sys sys.path.insert(0, '/home/wot/django-projects/aedo') import settings import django.core.management django.core.management.setup_environ(setti...

Customizing project and app templates in django

I would like to customize the files and folders created when running python manage.py startapp appname I find doing some things over and over again and I think it would be neat, if my customizations are present when I create a new app. Do you know where I can customize the default files when an app is created? ...

How to display a table of images in Django template system?

I'm developing a Django-based site for fun, and wondered if anyone knows how to solve this problem. I want to display images in a table, like a gallery, inside a template. Does anyone know how to do this? I've tried a multidimensional list, but I am getting nowhere. ...

DJANGO + Google App Engine, Getting Started Tutorial

I'm very interested in finding a up-to-date tutorial that shows steps for getting DJANGO running on Google App Engine, anyone know of any such tutorials? Surprisingly, Google's App Engine DJANGO docs are almost a year old. What gives? ...