I keep ending up at this situation where I want to use a dictionary very much like the one 'locals' gives back, but that only contains the variables in the limited scope of the function. Is there a way to do this in python?
A bit more about why I want to do this: I'm playing with Django and when I go to give my templates context, I am ...
I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache.
I'm running OSX 10.5 and have the standard apache (which refuses to run ...
I want to use the Django admin interface for a very simple web application but I can't get around a problem that should not be that hard to resolve ..
Consider the following:
class Contact(models.Model):
name = models.CharField(max_length=250, blank=False)
created_by = models.ForeignKey(User, blank=False)
I can't find a way t...
I have a view function, which is returning an html page.
render_to_response("test.html",{test:value,somehtml:'t'});
Now, the 'somehtml' value is rendered as string and not html tag.How can I return html tags?
...
DECOM_CHOICES = (
('N', 'No'),
('Y', 'Yes'),
)
class Host(models.Model):
hostname = models.CharField(max_length=36, unique=True)
decommissioned = models.CharField(max_length=1, choices=DECOM_CHOICES, default='N')
ip_address = models.IPAddressField()
def __unicode__(self):
return self.hostname
class HostAdmi...
Hey there,
I'm using PyAmf to communicate with a Flex app. But I keep getting errors.
My model:
from django.contrib.auth.models import User
class Talent(User):
street = models.CharField(max_length=100)
street_nr = models.CharField(max_length=100)
postal_code = models.PositiveIntegerField()
city = models.CharField(max_...
I've got a model like this
def upload_location(instance, filename):
return 'validate/%s/builds/%s' % (get_current_user(), filename)
class MidletPair(models.Model):
jad_file = models.FileField(upload_to = upload_location)
jar_file = models.FileField(upload_to = upload_location)
upload_to=tempfile.gettempdir()
How...
I'm working on an image portfolio app, and I've got a url which looks like this:
url(r'^(?P<slug_val>[-\w]+)/(?P<page>[0-9]+)/(?P<id>[0-9]+)/$', 'portfolio.views.imagedetail')
Essentially, the page element is only there so I can nicely redirect the user back to the page of thumbnails they came from. However, if the URL gets passed aro...
I am trying to add the datetime object of a person. Whenever the birth year is less than year 1942, I get a strange error DataError: unable to parse time when reading the data back from the DB.
class Person(models.Model):
"""A simple class to hold the person info
"""
name = models.CharField(max_length=100)
born = models....
When I get an error exception email from my Django site it would be useful to see the User and/or UserProfile information for the currently logged in user. How do I add this to the Django site exception error emails?
...
I have started work on a local app for myself that runs through the browser. Having recently gone through the django tutorial I'm thinking that it might be better to use django rather than just plain python.
There's one problem, I have at least 20 models and each will have many functions. Quite simply it's going to create one huge model...
For debugging purposes, I would like to have a variable in all my templates holding the path of the template being rendered. For example, if a view renders templates/account/logout.html I would like {{ template_name }} to contain the string templates/account/logout.html.
I don't want to go and change any views (specially because I'm re...
The book I've been reading about Django mandates heavy usage of a command line in terms of installing Python and importing Django. It details which command line commands are necessary, both from the command line itself and from a python shell, in order to create a new project, start a web server, perform synchronization of models to a da...
I've noticed that whenever I enable the database settings on my django project (starting to notice a trend in my questions?) it gives me an internal server error. Setting the database settings to be blank makes the error go away. Here are the apache error logs that it outputs.
mod_wsgi (pid=770): Exception occurred processing WSGI scrip...
I'd like to be able to include a reference to the currently authenticated user with a Note when working with Notes from the admin interface. The model would look something like:
from django.db import models
from django.contrib.auth.models import User
from datetime import datetime
class Note(models.Model):
datetime = models.DateTi...
In Django, I have two models:
class Product(models.Model):
name = models.CharField(max_length = 50)
categories = models.ManyToManyField(Category)
class ProductRank(models.Model):
product = models.ForeignKey(Product)
rank = models.IntegerField(default = 0)
I put the rank into a separate table because every view of a pa...
I have a webpage where I am looping,and using cycle inside the loop.
{% for o in something %}
{% for c in o %}
<div class="{% cycle 'white' 'black'%}"></div>
{% endfor %}
Now, this means everytime inside the loop, first div tag gets white.But,what I want is to alternate between white and black i.e. start with white, then next time wh...
Hi,
I am trying to fetch all status history of the user friends.Basically I am showing up
friend list with thr pics and name. so I wanted to put the link next to the name saying how many times user had updated the status. on clicking on the link I can see the whole history of the status updated by that guy.
Need help for writing fql.
t...
Hello,
I have a model with a created_by field that is linked to the standard Django User model. I need to automatically populate this with the ID of the current User when the model is saved. I can't do this at the Admin layer, as most parts of the site will not use the built-in Admin. Can anyone advise on how I should go about this?
...
I'm developing using Django on Windows. I have a model with an imagefield, and use a form to fill it. Images get uploaded without problem. The problem occurs when I attempt to show an uploaded image inside a template by coding this:
<img src ='{{object.image.url}}'/>
(object is an instance of the relevant model, and image is the name ...