ect but with id set to None.
>
> +1 -- obj.copy() might be a better syntax to mimic dict.copy().
obj.copy() would be a nice addition, but would it also copy the values
of many-to-many relationships? Like, if a poll is on multiple sites,
would poll.copy() return an object with the sites
tely don't use it on anything resembling a production site.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
google.com/group/django-users/browse_thread/thread/dc2197f0de69072a/d801feabc1144518
As soon as psycopg 2 is released officially (i.e., out of beta), we'll
add an "official" psycopg2 handler.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
at compares the
primary keys, so it's equivalent to doing "user.id == myuser.id".
Thanks for bringing this up! I've added a "Comparing objects" section
to the docs:
http://www.djangoproject.com/documentation/db_api/#comparing-objects
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ing admin
templates, it's probably best to start from the "real" templates
rather than retrofitting 0.90-style admin templates to fit the
template scheme 0.91 expects.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ng your settings
module. Do you have the line "SetEnv DJANGO_SETTINGS_MODULE foo" in
your httpd.conf, where "foo" is the Python path to your settings
module?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
or key, value in request.GET.items():
> q.append ( "%s = %s" % (key, value) )
> q = ", ".join(q)
> print q
> cmd = "milestones_list = milestones.get_values(%s)" % q
> exec cmd
UGH! Do *not* use that code.
m
> manipulator to use from my own views, but I would like the admin view to use
> the
> same logic.
You can check whether manipulator.original_object exists. If it does,
it's a change. If it doesn't it's an add.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ren't deleted.
The patch doesn't appear to handle this, which means we have
inconsistent behavior between bulk delete and normal deletion.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
d about repeating template code, I'd suggest
writing a template tag that does the work of displaying output for the
object_list/latest.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
On 1/18/06, Luke Skibinski Holt <[EMAIL PROTECTED]> wrote:
> The first link in this section
> (http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext)
> is broken.
Thanks, Luke. I've fixed it.
Adrian
--
Adrian Holovaty
holovaty.com
ode.djangoproject.com/wiki/DjangoFriendlyWebHosts
http://code.djangoproject.com/wiki/ServerArrangements
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
get any
errors, show us the entire CREATE TABLE statement generated by
"sqlreset" for the table that includes the genre_id field snippet you
pasted above.
We'll figure this out!
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
out of all Django doctests left. :-)
> Anyway it's late night already and my mind started to blur. I will
> try to finish up tomorrow, clean up, and submit patches.
Excellent! Thanks for your hard work on this.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ut, because
none of your views will share the same prefix. You'll have to put the
whole view name (e.g. 'django.views.generic.something' or
'project.apps.app_name.views.index') next to each URL.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
t_list()
Hey James,
You'll want to do this:
>>> from django.models.foundation import ratefunctions
>>> ratefunctions.get_list()
In this case, ratefunctions is a "magic module" which is created by
Django automatically. I know this is a bit confusing, b
On 1/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I wonder if it is the module_name statement in the META class?
Yeah, get rid of the module_name statement, and you'll be able to do
"from django.models.foundation import ratefunctions".
Adrian
--
Adri
I do this at this start of every django interpreter session:
>>> from django.core.db import db
>>> db.cursor().close()
>>> db.connection.autocommit()
Then you don't need to do a rollback and lose your cursor every time
you get a database error.
hunked parts. But to do this there would have to be
> support for chunked transfers in the mod_python handler, too, so it
> wouldn't be a simple patch, but a bit more involved.
I agree that this would be a fine feature to add. Anybody willing to
work on a patch?
Adria
dable, IMHO). is there any possibility to offer that functionality?
The Django admin site can't do that out of the box, but you could
create your own custom views that do that.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
cally put a
get_FIELDNAME_display() method on the model. In your example, your
model objects will have a get_difficulte_display() method.
http://www.djangoproject.com/documentation/db_api/#get-foo-display
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
s.get_list(domestic__exact="t");
Try this:
beers.get_list(domestic__exact=True)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
FAQ.
http://www.djangoproject.com/documentation/faq/#my-admin-site-css-and-images-showed-up-fine-using-the-development-server-but-they-re-not-displaying-when-using-mod-python
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
s prevents me from
> logging in into the admin interface.
Did you run the command "python manage.py install admin"? That command
creates the django_admin_log table.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ROP DEFAULT;
ALTER TABLE chicagocrime_ward ALTER COLUMN id SET DEFAULT
nextval('public.chicagocrime_ward_id_seq'::text);
I will edit the RemovingTheMagic wiki page to add this example explicitly.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
lates.
I was thinking we could add a CACHE_COMPILED_TEMPLATES setting and
change get_template() to give it a "cache" keyword argument, which
would default to the value of CACHE_COMPILED_TEMPLATES. Any quick
thoughts before I implement this?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
the relevant part of the docs:
http://www.djangoproject.com/documentation/syndication/#a-simple-example
Check out the part that begins: "To specify the contents of
and ..."
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
; method instead?
That's because prepopulate_from is intended to give *recommended*
values, not definitive values. If your slug prepopulates from your
headline, you still may want to edit the slug after it's been
prepopulated.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ss of MultiValueDict -- that's why the docs say QueryDict, not
MultiValueDict.)
If your request.POST is displayed as , that means
request.POST is empty. If request.POST had something in it, it'd look
like this:
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
to mention the security
implications of allowing
pure Python code in templates.
The Ruby on Rails people are realizing this, and they've made a
template language
that closely mirrors Django's: http://home.leetsoft.com/liquid/
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
g
> wrong with this?
Hi Roberto,
There shouldn't be any problems with this. That's exactly what I'd
suggest doing.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
plates, rather than something like
/home/templates/myapp?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ious versions
> documents.
>
> This would allow one page to reference previous documents, rather than
> have the tutorial page reference 0.90, 0.91, 0.92.. when new versions
> come out.
Hi Wade,
Thanks for the good suggestion! We'll change that when the docs for
next vers
this?
Easy! Just add blank=True to the "awards" field on Movie, like so:
awards = meta.ManyToManyField(Award, blank=True)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
API function for related objects, which is, in
your case, "self.get_product_group().name".
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
; Good one guys! - coming from effbot, I think that's praise indeed ;)
Fantastic news! That's an honor.
Getting feedback on Django (both good and bad) from Python luminaries
has been a total trip. :D
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
On 1/29/06, kbochert <[EMAIL PROTECTED]> wrote:
>
> Yeah -- just found it. Sticky key prevented saving of the polls.py
> file
> Why do these things always happen when I'm learning something new??
>
> On to the next stupidity.
No problem at all -- we should improv
that I got a _plaintext_ backtrace, not the
> pwetty one :)
>
> Is it a bug or intended behaviour? (backtrace was pretty much useless)
Hmm, I'd consider that a bug in the pretty error-page. How'd you
invoke the __repr__() -- in a template, or in view code?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
t.py line 65)
> I'm using SQLite.
Hi Karl,
Chances are you did some stuff in the tutorial out of order. Make sure
your polls/models/polls.py file contains some models, and make sure
the file polls/models/__init__.py includes the following:
__all__ = ['polls']
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
a good candidate for a validator. Just write a validator
(see examples in django/core/validators.py) and add it to your
FileField's validator_list parameter. This will let you check the file
size before the file is uploaded.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
t for subsequent accesses. There's no way to set variables in
the template language, but if you're wanting to save on typing, I'd
recommend passing 'blurb' as a variable in your template's context.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
;content"] > 1: # 10,000 bytes
raise validators.ValidationError, "Please enter a smaller file."
The trick here is to operate on field_data['content'] instead of
field_data. File-upload fields are a special-case; they come across as
a dictionary of {'filename'
s something I've always thought HTTP could not
> do...
As far as the validator I posted, it does the validation *before* the
file is saved to the filesystem, when it is still in memory.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ere are some known issues when
PHP and mod_python are enabled at the same time.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
On 1/30/06, Jiri Barton <[EMAIL PROTECTED]> wrote:
> I have two text input fields in a form. At least one of them is
> required. My question is, how can I check for this?
Hi Jiri,
Check out RequiredIfOtherFieldNotGiven and RequiredIfOtherFieldsGiven
in django/core/validators
is a text from test.html
> {%block mine%}Hello from test.html {%endblock%}
>
>
> I use this view with the template
>
>
> def TestTemplate(request):
> return render_to_response('board/Index1')
> ########
Make sure test.ht
people have different definitions of when they start,
etc.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ct instance or
(in the case of date fields) a datetime object.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
need a simple way of being able to specify an object to
> delete.
Nice explanation, Luke! I've added it to the FAQ.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
l need to run the command "python manage.py install admin".
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ment as
> well.
Hey Jan,
This is going to be fixed in Django's next version, which changes the DB API.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
of decoupling template settings in another
thread.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ription)
...becomes this:
f = foos.Foo(name=name.encode(), full_path=full_path.encode(),
description=description.encode())
I believe the next version of psycopg fixes this, but we don't have a
Django driver for it yet because psycopg 2 is still in beta. That
said, somebody wrot
x27;ve clarified the FAQ a tiny
bit, although it seems like clarifying it more could introduce
confusion. Really, it's just a log of every query made to the database
-- no more, no less.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
x27;ll just say
again, for the sake of the archives, that you need to use .encode() on
any Unicode string before passing it to the database layer.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
jango currently does, but it'll be
gone in the next version. To solve your problem, put the following in
your model's "class META":
module_constants = {'bar': bar}
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
tp://code.djangoproject.com/wiki/RemovingTheMagic
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
s, views and manipulators any way you want.
There's no restriction on where they live, as long as they're
somewhere on your Python path. The only requirement is that the module
that contains the URLconf needs to have three module-level variables:
urlpatterns, handler404 and handler50
leware/
The documentation page is your key to Django nirvana.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
So summing up - is there a way to fetch a given object + a related
> object, or do I have to do it with handmade SQL?
If you don't want to use select_related, you'll have to do it with
handmade SQL. We've talked about adding the ability to pass some
options to select_related but hav
model to avoid this problem entirely. The "choices"
parameter is intended for a finite list of choices that never change.
When you're dealing with data that needs to be dynamic, use the
database.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
On 2/8/06, Milton Waddams <[EMAIL PROTECTED]> wrote:
> I'm wondering if anyone has a filter which safely truncates html so as
> not to chop through tags.
Hey Milton,
You could try using the Python interface to HTML Tidy:
http://www.egenix.com/files/python/mxTidy.html
s the error:
> the_unternehmen = meta.ManyToOne(unternehmens.Unternehmen, 'id')
You want this instead:
the_unternehmen = meta.ForeignKey(unternehmens.Unternehmen)
You're never supposed to use meta.ManyToOne directly -- if you let me
know where you saw that, I will correct the doc
o this, after you've created the User object (u):
request.session[users.SESSION_KEY] = u.id
I've added a section to the docs:
http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in
Adrian
--
Adrian Holovaty
holovaty.com | django
url_re pattern accepts only url begins with "http://";.
Hey Eric,
Thanks for the pointer on this. I've updated the code in trunk to
accept "https".
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~--
On 2/10/06, Sebastien Fievet <[EMAIL PROTECTED]> wrote:
> TypeError: got unexpected keyword argument 'event__exact'
>
> What's wrong with my code ? (I've got the last SVN version of Django,
> v2299)
Hey Sebastien,
You need to use event__id__exact, not eve
in Django or why this is not used in Django as default?
I'm not sure I understand the problem -- could you give a bit more
explanation, possibly with an example?
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~--
havior. When you access an element
in a MultiValueDict, it returns the last item, as a string. See the
docs for more info:
http://www.djangoproject.com/documentation/request_response/#querydict-objects
If you want to get a list instead of a string, use
data.getlist('costs') instead of data[&
Hey Ned,
That's exactly how I'd recommend doing it. There's no sort of event or
scheduling framework within Django itself -- we've always relied on
cron to do repetitive tasks.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
is. We could
easily add a hook for you, though. The magic-removal branch has a new
dispatching framework (we're using PyDispatcher), so if you're willing
to wait for that, we can can add the hook there.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
;m looking for. Not
> an elegant solution, though.
Ah, right. By that logic, you could also put stuff in your settings
module, but I agree that it'd be inelegant.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
ttp://somedomain/admin/blah/authors/add/?author=foo
If you need to populate a foreign-key value, use the ID of the value.
http://somedomain/admin/blah/authors/add/?author=3
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
rgs):
return HttpResponse("Hello world.")
foo_instance = Foo()
If the above code lives in path/to/bar.py, you'd put
"path.to.bar.foo_instance" in your URLconf.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~
with which future logins do not work.
Hmmm, I don't recall anybody having this issue, so I suspect it's
something with your code. Are you, perchance, subclassing the
auth.User model or doing anything else custom with the auth app?
Adrian
--
Adrian Holovaty
holovaty.com
other causes), please speak up.
http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are sub
ks.
I've updated the documentation:
http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are
bject, not the cursor object.
cursor = db.cursor()
cursor.execute("UPDATE something...")
db.commit()
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are
ot; here:
http://www.djangoproject.com/documentation/model_api/#admin-options
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django user
place --
foods.get_object(pk=whatever) -- pass the select_related=True
argument. That'll automatically grab and cache the related Period
object as well. For example:
foods.get_object(pk=3, select_related=True)
If you don't do select_related=True, your call to f.get_period() will
execute
stom methods aren't supported in list_filter. In order for that to
work, Django would have to select every single record of the database
and filter them in memory, which is not something we want to do.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~--
On 2/22/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> How could we have a user login to a django-powered app over ssl?
Hi Chris,
There's nothing Django-specific about using SSL. Just set up your
certificates and stuff in Apache and set up Django as usual. It just
works.
Adr
is, just write your
views and don't make any database calls; it's simple. :)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
&quo
odel so it wouldn't make much sense to use them without
database tables.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django us
#x27;s the most stable and has
the latest non-magic-removal features. The magic-removal branch is
still for living-on-the-edge developers at this point.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You rec
ome people might be using, for example, get_object(limit=1), relying
on the fact that get_object() would be using the model's ordering.
However, I think this is an acceptable change, as long as we document
the change on the backwards-incompatible changes page. Any objections
before I check in
As of revision 2392 in trunk, I've made this change. ORDER BY is no
longer added for get_object() queries, unless you explicitly specify
it. Thanks again for suggesting, Ned!
Adrian
--~--~-~--~~~---~--~~
You received this message because you are subscrib
so do some sort of
database replication, but I haven't had to deal with that in my
experience.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Dja
u can put whatever the heck you want in views.py -- it's just a
normal Python module, with nothing magic about it. If you paste your
full traceback, we may be able to help debug your problem.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~--
On 2/24/06, hsitz <[EMAIL PROTECTED]> wrote:
> Back in middle of last year Adrian Holovaty posted some very helpful
> information on how to get the raw output of admin templates for use as
> basis for your own views. I'm a newbie trying to get my head around
> Django, an
has anyone had any other thoughts about how to implement
> this?
Yeah, we talked about this on Sunday at the Django sprint. The
tentative plan is to introduce a CurrentUserField which is
special-cased in the admin logic.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.c
e
could roll this into Django proper in a generic way if there's a
demand.
Alternatively, SQLAlchemy solves this problem by implementing an
identity map, which is quite cool. You should be able to use
SQLAlchemy with the rest of Django with no problems at all -- the only
thing you won't be
go is
to activate potentially complex/performance-heavy features only on an
opt-in basis.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"D
ss/ . No problems. And
if/when there are problems, they'll be at the database level, not at
the Django level.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
we were to allow
certain views to be left out of the cache, the cache middleware would
have to do URL dispatching to find out what the associated view is,
then check the view to see whether it should use the cache, then
finally check the cache. The extra overhead of URL dispatching isn't a
hug
stable
trunk, or the latest released version (0.91) if you're starting with
Django. The magic-removal branch remains for core developers only at
this point.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~---~--~~
You received this mes
still kinda-sorta affordable in the grand scheme
of things if you're serious about making Web apps.
Note that I'm not affiliated with 1and1 in any way, and I'm sure there
are plenty of other (even cheaper) alternatives.
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~
, anyway? I'm not in a
position to apply the patch to my local copy.)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
called calendar :) You
> can tell I'm new to Python (and Django)
Yeah, that one got me when I was learning Python, as well. :)
We ought to improve manage.py to disallow project names that conflict
with common Python standard-library modules...
Adrian
--
Adrian Hol
orted. To accomplish what you
want, you'll have to write either a custom tag or filter. (It's easy
enough to do.)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
ailable ID
in _pre_save(). Then compute your value based on that.
* Write a trigger at the database level that automatically calculates
the computed field whenever a record changes in the table. This would
be entirely out of Django's control,
801 - 900 of 1037 matches
Mail list logo