Currently
I have an inclusion tag that is coded something like this:
@register.inclusion_tag('forms/my_insert.html', takes_context=True)
def my_insert(context):
# set up some other variables for the context
return context
In my template, I include it by putting in {% my_insert %}
New Feature Request
We now want to test a ne...
Hi all,
I have started using django-piston for creating APIS but I am having trouble finding documentation on how to consume the API from inside django with python. I have seen examples using javascript.
So far I am using urllib to access the API but I wonder if this is the best approach.
I appreciate your input on this!
...
Currently I'm using the below code to allow a user to download a file that's attached to a couchdb document. I'm using couchdbkit with Django.
def get_file(request, user_id):
user = User.objects.get(pk = user_id)
application = user.get_profile().application()
attachment_name = request.GET.get('name', None)
assert attachm...
Using {{today|time:"TIME_FORMAT"}} correctly localises times when I switch languages in my Django 1.2.3 project. E.g. for English I see "12:19 a.m." and when I switch to German it changes to "12:19:25".
As far as I can tell from looking at the docs and code (defaultfilters.py and formats.py) just using {{today:time}} should do the same ...
If I have the following models in a Python (+ Django) App Engine app:
class Album(db.Model):
private = db.BooleanProperty()
...
class Photo(db.Model):
album = db.ReferenceProperty(Album)
title = db.StringProperty()
...how can I retrieve all Photos that belong to a public Album (that is, an Album with private == False)?
To fu...
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash.
When I try creating a django project in pydev, I get an error: "Django not found."
What could the problem be?
...
Hi guys,
how do i use the models to perform a join and count query like the one below:
select count(*),site_url from connection_ss
join site_ss on to_id_id = site_id
where site_ss.source_id = 1 group by site_url order by count desc
Here are my models:
class site(models.Model):
site_id = models.AutoField(primary_key=...
In Django's settings I can specify the domain that is used for session's cookie - like it is stated here. It's quite useful for me, as I have subdomains defined that should share the cookies with master domain - so I define the SESSION_COOKIE_DOMAIN = '.domain.com'.
What I bumped into now is the requirement to serve many domains - like ...
I have a FormWizard where I need data from the first form to pass to the constructor of the second form so I can build a dynamic form.
I can get the first form's data via the process_step of the FormWizard.
I create the fields of the second form with a database call of the list of fields.
class ConditionWizardDynamicQuestions(forms.Fo...
Hey Guys,
How would you go about making a pluggable django app, that can accept data from any model and then perfom some action with that data (i.e Save to DB, Send email). This functionality should be generic and should not be tied to a specific model.
...
Hi folks,
the user needs to provide a list of field/values through a form
class FieldForm(forms.Form):
field_name = forms.CharField()
field_value = forms.CharField()
The problem is how do I get a user to pass multiple of these with one submit?
Also as a side question... any tips on implementing editing too?
Any ideas? ...
I have two tables, tasks and projects. And every task has a project (and every project can have N tasks).
When adding or editing a task, projects are displayed as dropdown as it should, but dropdown is ordered by ID (or no ordering at all). Because i start to have plenty of projects, is there a way to get projects in a dropdown in alpha...
I've setup nginx, fastcgi and django. The run my django project through fastcgi using:
python26 manage.py runfcgi host=127.0.0.1 port=8080 --settings=settings
When I visit http://127.0.0.1 I can see the normal django 404 since I haven't setup everything on my django project aside from the admin. So I tried visinting http://127.0.0.1/a...
This is actually a follow-up to a previous question.
A user's profile data is spread over several different models, like so:
# Simplified versions, actual classes contain many more fields.
class Profile(models.Model): # returned by Django's User.get_profile()
user = models.OneToOneField(User)
home_address = models.OneToOne...
Does anyone have or know of a good template / plan for doing automated server upgrades? In this case I am upgrading a python/django server, but am going to have to apply this update to many machines, and want to be sure that the operation is fully testable and recoverable should anything go wrong.
Am picturing something along the lines...
I have a simple many-to-many relationship based around a through class.
class Person(models.Model):
friends = models.ManyToManyField('self', through='Friendship')
class Friendship(models.Model):
me = models.ForeignKey(Person)
them = models.ForeignKey(Person)
confirmed = models.BooleanField(default=False)
This should, ...
When running a Django unit test, it try's to install a fixture (initial_data.json) to the db, but fails everytime due to Runtime Error: maximum recursion depth exceeded while calling Python object
Any idea what's going on?
Edit: Django 1.2.3 and Python 2.7
...
Hi,
I've got a model Child inheriting from a (non abstract) model Parent.
For a given instance parent of Parent, how can I know if it's a Child?
If it is,
parent.child
returns the child, but otherwise it returns a DoesNotExist exception.
Is a try/except the only way to check that?
Thanks
jul
# EDIT
I've just find the same quest...
I would like to filter a queryset by whether a certain subquery returns any results. In SQL this might look like this:
SELECT * FROM events e WHERE EXISTS
(SELECT * FROM tags t WHERE t.event_id = e.id AND t.text IN ("abc", "def"))
In other words, retrieve all events which are tagged with one of the specified tags.
How might I exp...
What's the point of using template structure like this:
templates/
app/
article_view.html # or view_article.html
category_view.html
vs
templates/
app/
article/
view.html
category/
view.html
It's easier to find particular template with second approach, but I almost don'...