I followed all instructions regarding the intallation of the
development version of Django on Leopard.
I’ve created the symbolic links but I keep getting two error messages:
The first one trying to rum django-admin.py command not found
The seccond trying to import django in the python shell
After moving to the latest version of Django one of the functions I
wrote fails to work.
I'll drop the code...
def year_cal(sectie, req_year = None, req_month=None):
cur_year= str(datetime.datetime.now().year)
cur_month= datetime.datetime.now().strftime("%b")
all_month_list = ['jan', 'fe
For a given django site there are many urls.py's. The system also
knows what apps are installed. Wouldn't it be nice to make an app that
uses this knowledge and add some extra functionality to manage a
website menu?
At the moment I have no idea how to implement it but it should be
something websi
I'm trying to implement a kind of model but I'm stuck. Maybe someone
outhere can give me some help?
This is what I'm thinking about:
A site can have sections and a section can have apps. Also a site can
have apps.
For example:
Site: gardening.org
app: news
sections: garden/kitchen
garden apps:
Within a template I want to use the folowing construction.
{% for item in object_list reversed %}
{% ifchanged %}
{% if not forloop.first %}{% endif %}
{{ item.pub_date|
date:"F" }}
{% endifchanged %}
{{ item.title }}
For a model I need subclassing which is work on progres. Falling back
to a OneToOne approach seems tricky because "the semantics of one-to-
one relationships will be changing soon". I'm wondering now what to
do. Here's my model in the OneToOne approach.
class Cropcat(models.Model):
parent = mo
class Category(models.Model):
name = models.CharField(maxlength=70)
parent = models.ForeignKey('self', blank=True, null=True,
limit_choices_to = {'parent__isnull': True})
I dont want to be able to select a parent which is actualy the
category currently edited.
I tried a custom validator bu
For a class method I want to use the value of the
Model>Meta>verbose_name.
Can someone tell me how to get this value?
Thanks, Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to thi
This is my model and I use a custom save to prevent the creation of a
category with a parent_id which is the same a the current_id (child of
itself)
class Category(models.Model):
name = models.CharField(maxlength=70, unique=True)
slug = models.SlugField(maxlength=50, unique=True,
prepopulat
Hi Greg:
Just started using it yesterday :-)
http://code.google.com/p/django-template-utils/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@
Addition:
> This is my model and I use a custom save to prevent the creation of a
> category with a parent_id which is the same a the current_id (child of
> itself)
When an error occurs an ugly error message apears so I tried to create
a custom validator.
Custom validator didn't work because of
Hi Mike,
I have the same problem with my model. (Link below)
Reading your "points to a .validate() on the model" raises the
following question.
Have you tried it?
http://groups.google.com/group/django-users/browse_thread/thread/bd2b2c24f3879690
--~--~-~--~~~---~--~-
I want to create a pattern to get one or more occurences of, let's
say, slug.
/bla/
/bla/blob/
/bla/blob/blebber/
/bla/blob/blebber/and_a_lot_more
etc.
I get it working for up to two slugs with
('^([^/]+)/([^/]+)/$', 'page'),
def page(request, *slugs):
slug_list = []
for slug in slugs:
Hi Malcolm,
SMART
Thanks
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [
Can someone please explain to me how to create a form which provides
not only the fields for the object but also the fiels for a related
object (foreign key) and the best method to validate and save the
data?
Thanks in advance,
Rob
--~--~-~--~~~---~--~~
You rece
Hi Thomas,
Thank you. I managed to get 2 forms in a view but I dont know how to
provide some 'default' data to some fields in the related form.
I'll give you some code:
class Infocard(models.Model):
from django.conf import settings
content_type = models.ForeignKey(ContentType, limit_choic
Using an inlude tag on my homepage to get a list of current polls
requires a template. This template lists the polls and provides a link
for the details. I need to give an url including the modulename:
(a href="/polls/5")
I don't like this approach so I want to ask if it is possible to use
an obj
> Can you give some more details, please? I cannot puzzle out what you are
> currently doing here.
Hello Malcolm,
It's about in the template.
Here come the details...
### mysite/polls/templatetags/poll_tags.py
from django import template
from mysite.polls.models import Poll
register = templat
For a project I need to record customer information such as name,
address etc.
I doubt about the best approach to create this functionality.
Shall I use the user class in contrib.auth and extend it or shall I
create an independent customer class/app?
The first approach serves me the default authe
Sorry, I should have searched smarter before posting.
Found the anwers at
http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
T
To be able to control a template output based on a current remote
address, I created this model.
class Poll(models.Model):
question = models.CharField('vraag', maxlength=200)
pub_date = models.DateTimeField('publicatie datum')
voted_by_remote_addr = False
def set_voted_by_remote_addr
Hi Kevn,
May be of interest:
http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration
http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
I'm trying to get a very simple relationship to work but I can't figure
ou how to do this in Django.
This is what I want.
Poll ---<< question
Poll ---<< vote
A user can vote a poll just once. I check this using a function which
gets the remote ip.
This is the models.py snippet
class Poll(mode
Rob Hudson schreef:
> I'd kind of think that in Vote you don't need the poll FK, just the
> choice since the choice then maps to a particular poll.
But how do I prevent a voter to vote more than once on a poll?
--~--~-~--~~~---~--~~
You received this message be
Thank you guys.
Without a poll_id in vote it isn't possible to check integrity in the
database so I keep it :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send emai
In a models.py I have created the folowing function. Top level, not in
a class.
def get_unvoted_polls_for_voter_ip(ip):
from django.db import connection
cursor = connection.cursor()
sql = """SELECT polls_poll.* FROM polls_poll
LEFT OUTER JOIN polls_vote ON polls_poll.id = polls_vot
In a models.py I have created the folowing function. Top level, not in
a class.
def get_unvoted_polls_for_voter_ip(ip):
from django.db import connection
cursor = connection.cursor()
sql = """SELECT polls_poll.* FROM polls_poll
LEFT OUTER JOIN polls_vote ON polls_poll.id = polls_vot
For a model I have defined two table fields.
To fill those fields in admin I want to provide an extra dropdown
field.
Is it possible to add an extra field to the model without creating a
corresponding database field?
The use:
field1 = content_type_id
field2 = content_item_id
Extra dropdown fi
I get this error in admin when saving a new article.
Can someone please help me?
Complete model...
from django.db import models
from django.core import validators
class Article(models.Model):
pub_date = models.DateTimeField('date published')
published = models.BooleanField()
headlin
After many many trail and error I maybe found a 'bug'.
I simplefied the above model till it worked again. Then I added the
next field option and the error arose.
"unique=True" in MenuItem > name
Complete simplefied model with error:
###
from django.db import models
cla
After solving a problem described at:
http://groups-beta.google.com/group/django-users/browse_frm/thread/b453f0c91e29cc04?hl=nl
I continued developping my model. Unfortunately a new problem arose.
Given the following model, I get an error message in admin after
successfully saving an article and
On 10 dec, 17:42, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> What is the error you are getting?
It's the 'subject'
Cannot resolve keyword 'caption' into field
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
In a model I feed a contenttype form field some initial data to choose
from.
class MenuItem(models.Model):
CONTENT_TYPE_CHOICES = tuple(get_available_content())
content_type = models.ForeignKey(ContentType,
choices=CONTENT_TYPE_CHOICES)
The data is provided using the folowing function whic
> Your solution seems to be some misunderstanding :)
> If you set a foreign key to ContentType, then it already gets the
> choices from the relation.
Dear Aidas,
I know, I know. The point is that I want to be able to use the damn
generic relation in admin. I abuse the given field to collect real
I installed Luke Plant's Tagging App and started reading the README
file and the comments provided in the source. Compared to the marvelous
Django Book and -tutorial this reading isn't very funny :-)
Has someone a simple example for how to include a tag in another model,
say Poll or Article?
And
Maybe this may be of any help. In the model you can add adminlinks like
this:
class Admin:
fields = (
)
list_display = ('name', 'admin_links')
def admin_links(self):
return 'edit | view | delete' % (self.id, self.get_absolute_url(),
self.id)
Hi Milan,
> Is there a workaround for that?
Sorry I don't know.
>I'll write my own views.
Maybe you can expand the admin using your own views. Take a look at the
next app for some ideas:
http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki
Success.
Rob
--~--~-~--~~-
Hi Milan,
> Is there a workaround for that?
Sorry I don't know.
>I'll write my own views.
Maybe you can expand the admin using your own views. Take a look at the
next app for some ideas:
http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki
Success.
Rob
--~--~-~--~~-
> >That's easy.
Hi Timm,
Okay, this is a very simple example :-)
But Luke Plant's Tagging App modell is realy a bit more comple.
See>>
http://groups-beta.google.com/group/django-users/browse_frm/thread/a7cbd4fd843583be/5ef4a59b78dbb2e1?lnk=gst&rnum=1&hl=nl#5ef4a59b78dbb2e1
--~--~-~--
> paulh, take a look at
> thishttp://net-x.org/weblog/2006/nov/29/django-generic-relations-made-eas...
Hi Antoni,
Seems interesting but the code isn't yet available I suppose...
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
> tagging app from Luke Plant
> zyons
> the tagging app that jay parlar developed
It seems that more and more tagging apps appear while using generic
relations in admin will be available in a future Django. The last few
days I've been strugling to create a menusystem. A kind of tag system
but usi
For my project I created a templatetag which handles login, logout, get
profile etc. This way I can show a login/out box on every page by
including the tag in the main template.
There is one problem.
After logging out I want to redirect the user so the cookies etc, are
gone.
This is what I did (
Hi Dirk,
I think it's the other way around, try this
class Content(models.Model):
title = models.CharField('Title', maxlength=255, core=True)
body = models.TextField('Body text')
class Admin:
fields = (
(None, {'fields': ('title','body',)}),
)
list_disp
Try to delete your cookies.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EM
> I guess the next thing for me to do is to spend alot of
> time with the documentation and built a couple of simple apps/tutorials
> to flush out my understanding of how Django will work.
>
Hi Thomas,
And don't forget to look at the http://www.djangobook.com/
Rob
--~--~-~--~~
When I look at the urls.py file belonging to django_website I can't
figure out how the website handles the pattern for
www.djangoproject.com/
The only option seems to be the included flatpages.urls but this one
needs a pattern for an url.
Does anybody have a clue?
Here is the code:
urlpatterns
> I'd like to be able to edit Project and News separately with Content inline
> instead. Do you know what i mean?
Hi Dirk,
I get the point though I think this will not work. I've tried similar
things when creating a menu, where a menu "one to oned" to a poll item
or blog entry. I gave up.
In th
> The 'homepage' is a flatpage with an address of '/'.
Hi Kwe,
Great help!!!
I still can't figure out however how the flatfiles are loaded?
For example:
http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/flatfiles/homepage.html
--~--~-~--~~
> I still can't figure out however how the flatfiles are loaded?
Or maybe the homepage template from flatfiles is used, without using
the content for the flatpage at all.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Gr
Maybe we should create some kind of pressure group for this :-)
I don't have any idea who can be consulted for this subject, do you?
Cheers,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" grou
This is my model and it works in Admin due to the efforts of Antoni.
(see link at the bottom)
What I want to do is to add a collumn to the inline editing list
representing some field from the related content_object. Is there an
easy way to do this?
class Category(models.Model):
name = models.
Please provide your model. Something is wrong with the tags attribute.
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
T
Hi Cathy,
Chris is right. User in entrystatus is a relation to User. This isnt't
the same as a 'normal' field like Name or Title. Look at these:
Entry.objects.filter(blog__id__exact=3) # Explicit form
Entry.objects.filter(blog__id=3) # __exact is implied
Entry.objects.filter(blog__pk=3) # __pk i
For a model I want to add a custom manipulator which can be used in the
admin.
With this manipulator I want to be able to add an extra formfield for
displaying some additional data from a related object. There is no need
for database storage.
In this group I red that it isn't possible to extend
On 20 dec, 10:54, "patrick k." <[EMAIL PROTECTED]> wrote:
do it like in any other application:
custom view, custom template, change urls
Hi Patrick,
That's exactely what I wanted to know for one exception.
How to call the custom view when using admin.?
By overriding the 'default' call:
(r'^a
Hello Aidas,
Exactly. You answered your question yourself.
Seems I'm on the right way then :-)
Thanks for anwering, I'll give it a try.
Regards,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django
us
I've a template which will be included. Within the template I want to
include it again if needed.
child_list.html
{% if categorie %}
{{ categorie.title }}
{% if categorie.child_set.all %}
{% for categorie in categorie.child_set.all %}
{% include "child_list.html" %}
In my model I need a special character for the verbose_name_plural.
I need an ë but admin gives a questionmark.
What do I need to do?
The folowing things don't work.
verbose_name_plural = 'categoriën'
verbose_name_plural = 'categoriën'
verbose_name_plural = 'categori%sn' % chr(235)
--~--~---
Given this save function in one of my models, I want to display an
error message in admin instead of a errorpage.
def save(self):
try:
cur_id = int(self.id)
except:
cur_id = 0
p_list = self._recurse_for_parents(self)
cats = Category.objects.filter(folder__ex
Hi James,
When I write a custom validator like: isValidCategory() I need a
manipulator, validator and a form. Is there a way to use the 'current'
ones and to expand these or do I need to create them from scratch?
--~--~-~--~~~---~--~~
You received this message b
Thanks James,
I'll try this one
def IsUniqueForPath():
...
class Category(models.Model):
...
parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set', validator_list=[IsUniqueForPath])
--~--~-~--~~~---~--~~
You received this message
Hmm,
I wrote this in my models.py. Errors rased are just for debugging.
class HasUniquePath(object):
def __init__(self, cat_obj, error_message=gettext_lazy("No unique
path!")):
self.cur_cat = cat_obj
self.error_message = error_message
self.always_test = True
def __call__
My model uses a single table parent-child relationship.
I got the parent representation working but I isn't sorted right.
So I tried to sort the list of objects, returned by objects.all()
in the model class:
def __cmp__(self, other):
return cmp(self.get_absolute_url, other.get_absolute_
Sorted works great but I have problems using it im my custom manager.
I'm trying and trying but I can't figure out how to handle the
following situation.
class SortedTestcatManager(models.Manager):
def get_query_set(self):
QS = super(SortedTestcatManager, self).get_query_set()
SQS
And of course a new kind of sorting function. Thank's to you :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscri
Hi James et all,
Because of what I want it isn't possible to just rely on a validator, I
need a manipulator to get a request object.
The manipulator only has to add an extra validator to one field. This
validator validates using the database. No custom form is needed. The
manipulator will be use
For one of my models I need to do some extra validation.
Because of what I want it isn't possible to just rely on a validator, I
need a manipulator to get a request object.
The manipulator only has to add an extra validator to one field. This
validator validates using the database. No custom for
"Like FileField, but validates that the uploaded object is a valid
image. Has two extra optional arguments, height_field and width_field,
which, if set, will be auto-populated with the height and width of the
image each time a model instance is saved."
So I made this model:
class Foto(models.Mod
Kamil Wdowicz wrote regarding to handling loops:
{% for a in list|slice:"1" %}
{{ something }}
{% endfor %}
{% for a in list|slice:"1:3" %}
{{ something }}
{% endfor %}
{% for a in list|slice:"3:" %}
{{ something }}
{% endfor %}
What can be done to fill a table with a given list?
--~--
{% ifequal forloop.counter 1 %}odd{% endifequal %}
{% ifequal forloop.counter 3 %}odd{% endifequal %}
{% ifequal forloop.counter 5 %}odd{% endifequal %}
Is there a way to calculate this kind of thing, something like:
{% ifodd forloop.counter %}I am very odd{% endifodd %}
--~--~-~--~
This is working great, thanks!!
While on it, there are more filter like solutions for instance ADD. Is
there also something like DIVIDE, MULTIPLY etc? Or can these be custom
made?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Go
On my base template I have a block, say X
One level down there is a section template (extending base)
overwriting block X
Further down there are templates (extending section). On these
templates I want to be able to get the original value of X.
I tried
{{ block.super }}
{{ block.super.super
Before re-inventing, I want to ask if there is some build-in for
getting objects for [a || this] week.
Something like:
objects.filter(pubdate__week=now.week)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Djang
For a several models I use a FK to photos. The drop down in admin to
choose from lists all photos.
Can this list be filtered so I can restrict the available photos for
some models?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the G
Sorry that isn't working (at least not in my template )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from t
For those interested:
### INIT ###
import datetime, time
from django.http import Http404
def trans_month(month):
"""Vertaald de locale maandweergave naar globale"""
if month == "maa": month = "mar"
elif month == "mei": month = "may"
elif month == "okt": month = "oct"
return mont
When running Django using mod_python you have to restart Apache
whenever you make changes to your code. Some changes don't require a
restart so I wonder which changes trigger mod_python to reload and
which don't.
--~--~-~--~~~---~--~~
You received this message bec
Also beware that mod_php can give you session troubles on some systems.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To uns
Hi guys,
Can someone please tell me what can be done with the site feature in
admin?
And now I'm on it: from the ducumentation I understand that it is
possible to use admin interface parts in your own apps by calling
classes. Am I correct?
--~--~-~--~~~---~--~~
Y
To create hierarchical menu's, the first thing I thought about was
some kind of parent child relation on just one table but then you have
to submit many queries. A better approach wil be the Modified Preorder
Tree Traversal. See:
http://www.sitepoint.com/print/hierarchical-data-database
On the Dj
Is there a way to get a model's content_type_id?
I need it to store an object's id and content_type_id in another
table.
Currently I solved this by using an sql-statement but maybe there is
some 'hidden' property or function like:
self.content_type or self.get_content_type
--~--~-~--~--
I tried to use stringformat within a template but without success.
This is what I want in 'normal' syntax':
return "%.2f" % total_amount
It returns a two decimal value.
But how to use it in the template???
--~--~-~--~~~---~--~~
You received this message because
Is there a way to get an object's content_type_id?
I need it to store an object's id and content_type_id in another table.
Currently I solved this by using an sql-statement but maybe there is
some 'hidden' property or function like:
self.content_type or self.get_content_type
--~--~-~--
Dear Geert,
I entered {{ total_amount|stringformat:".2f" }} and it realy worked :-)
Actualy I red the STRINGFORMAT docu but I didn't get the clue. Now I
do...
Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Group
Is it possible to add some initial value to a forloop.counter?
This would be handy when using limit and offset.
More general, is is possible to use template vars as values for
calculations:
{{ var1 }} + {{ var 2 }}
--~--~-~--~~~---~--~~
You received this message
I've added an example view and template at:
http://code.djangoproject.com/wiki/CookBookViews
Good luck.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to dj
I don't know. I'll have a look.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
Hi Malcolm,
{{forloop.counter|add:offset}} works fine.
Thanks,
Rob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubs
Thank you, I'll have a look.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EM
Hi,
Django’s documentation shows a sample form wizard template.
In that template there is a conditional tag: {% if wizard.form.forms %}{%
else %}
I can’t figure out when this condition will ever by met.
Does sombody have a clue?
Cheers and happy coding,
Rob
--
You received this message b
Babatunde wrote:
It is satisfied when the step contains a formset
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
T
91 matches
Mail list logo