How to perform such simple query:
select p.text, b.title from books b, phrase p where p.book_id = b.id
on tables
books{
id : int,
title: varchar
}
phrase{
id : int,
book_id : int,
text: varchar
}
but using django models?
--~--~-~--~~~---~--~~
You received thi
Hi all,
I cache my view that show a list of stories, but I have also small
voting button (like digg). Voting is done be middleware class (it
reads user IP), so I can ask for view with list of stories and tell
that this list shall be cached and I have to ask middleware for vote
results.
Unfortuna
per-view cache is not a solution because I need only a method to
retrieve fresh (not cached) data from middleware.
I wanna take cached list of stories and not cached vote results for
it.
regards, Norman
On Jul 21, 3:13 pm, Michael wrote:
> On Tue, Jul 21, 2009 at 9:02 AM, Norman wr
Hi,
Is there any app that can be used as comment - under blog entries -
and as forum - to see all blog comments ( /forum).
regards, Normanek
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To p
hello,
I look for email alert functionality, where readers sign up to get
notifications when news happens. But I can't find any suitable django
app.
So where can I find something like this?
Any snippet or source code?
regards, nomanek
--~--~-~--~~~---~--~~
You
Hi,
I'm trying to test simple portal with two apps and two sub domains
mysite.com and blog.mysite.com, but I cant find any example of ngnix
configuration file on local ubuntu server.
So my question is - how to setup ngnix and django to test such
multihost on single django instance and local pc?
Kenneth Gonsalves escribió:
>
> On 06-May-08, at 9:37 AM, Jason Ourscene wrote:
>
>> def __unicode__(self):
>
> def __unicode__(self): <- space after 'def'. If you use a
> python editor it will find errors like this
>
and what editor do y
testing an object creation?
It's reasonable.
I'd probably just use count instead of len(), it should be faster and
more clearly indicates what you are testing. I'd also use assertEqual
instead of assertTrue for clarity.
before_count = Cartera.objects.filter(usuarioID=user.id).cou
del. http://www.djangoproject.com/documentation/contenttypes/
Ditch/copy Django's auth and roll your own/modify it to work they way
you need.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Dane Hesseldahl wrote:
> How do I get to the image when the avatar field has an image uploaded
> through it?
http://www.djangoproject.com/documentation/upload_handling/
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Sta
ch. Probably works with trunk as well.
Is this new? I really thought numerical indexing did not work.
Are you not using trunk? If not you should be, and if so there must be
something else going on (username instead of user_name?) as t
hole splitting dynamic/static content issue until and if
I run into scalability issues.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun! Check out Austin360.com for all the
lts in the wanted ordering.
> When rendered in html, I loose this precise ordering.
If you use the same code in your view as above then the ordering should
not change.
How are you displaying in template? Should be using something like
{% for article in articles %}
stuff
{% endfor %)
jelle wrote:
> Hi Norman,
>
> Yep, I'm just looping through the list.
> Pretty awkward, right?
Yes, very. Is the html output order seemingly random? or is there some
pattern to it? Cn you post the code for the view? I'm guessing there
is a typo or something s
quot;id", flat=true)
courses = Course.objects.filter(users__id__in=user_ids)
I've used 'in' with a many hundreds ids. Have no idea how performant it
is compared to other solutions.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
resumes
ends with one.
Another problem is your regex's don't include ^ match start of text.
Without you t run into problems with regex doing partial match at end of
string. Just like you are having your example.
Since you omit the match start your 1st urls matches:
/resumes/jss/no-
before i decided it was not tool I'd want to use for deployment
> My deployment procedure will be, I hope, an easy one:
>
> * download the version I want to deploy of the project (from
> subversion)
> * update database if needed
> * restart application server if needed
stomized pages:
The request instance that each view receives has a request.user
attribute which is the current user (could be anonymous) see
http://www.djangoproject.com/documentation/authentication/#users
This can be used to customize the view for the user in whatever way you
desire.
--
Nor
free books, blogs,
cookbook/snippet site, IRC, and mailing lists. Help is abundant and in
many forms.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August! Keep your cool with the Stat
l-patterns
url tag in
templateshttp://www.djangoproject.com/documentation/templates/#url and
reverse() in views/models/other to be excellent solution and the best
way to handle this.
Define your urls once in one place, your urls.py file. Change them and
magically everything else just wor
Robert wrote:
> Hello all,
Can we see your view code please?
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
It's August! Keep your cool with the Statesman. Check out our hot
deals
abels
labels = property(_prop_get_labels, _prop_set_lables, doc="""lables!""")
Then your assignment
article.labels = labels
won't throw an exception, at least not for same reason ;)
--
Norman J. H
presentation (text fields, with "now" etc. shortcuts)?
>
> Like, e.g.
>
> Created: 08/25/2008 09:20am
>
> Do you have links to examples?
http://www.djangosnippets.org/snippets/937/
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
One way to do this is to create helper functions.
def _get_artist_hometown(self):
return self.artist.hometown
list_display = ('album','release_date',_get_artist_hometown)
There're different options see
http://www.djangoproject.com/doc
all my apps plus
settings.py file in that directory.
some reading http://www.b-list.org/weblog/2007/nov/09/projects/
and
http://www.pointy-stick.com/blog/2007/11/09/django-tip-developing-without-projects/
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
__
ducts])
def test_sum_products(self):
order = Order(number=1)
product_list = [Product(price=20.0), ]
self.assertEqual( 20.0, order.sum_products(product_list) )
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
_
ything will work if
you get rid of all of it. You need to add what Django requires.
But, it sounds like you don't know/understand Apache conf files which
you probably should.
--
Norman J. Harman Jr.
Senior Web Specialist, A
instead of preserving the '+' symbols.
>
> Is there a way to prevent that?
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
http://docs.djangoproject.com/en/dev/topics/templates/#id2
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
lect the correct template
like so:
t = loader.get_template('%s_list.html' % model.__name__)
Create a wrapper aka "interface" or "proxy" that translates a standard
set of fieldnames into the model specific fieldnames. So as far as the
template is concerned th
ho-we-
> are', u'how-we-are-different')' and keyword arguments '{}' not found.
>
> What am I doing wrong?
Do you use {% url %} tag in that template 'dynamic_page.html'?
and I think it's better not to use *args, **kwargs unless
= MyForm()
add_links_to_context(context)
render_to_response(...
function handle_form(request, where_to_redirect_to):
form handling logic here
HttpRedirect(where_to_redirect_to)
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
_
;, line 7,
> in
> from django.db.models.fields import DateField
> File "C:\tools\Python25\lib\site-packages\django\db\models\fields
> \__init__.py"
> , line 666
> class DecimalField(max_digits = 32, decimal_places =
> 0)IntegerField(Field):
>
advice. Esp based on the little bit of
information you have provided.
It is also probably not a Django question but a sysadmin question.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the
;, {} 'profile_myiq'),
The error indicates you were providing either empty string, '', or the
litteral characters '', (not sure the formating, probably is the former)
Neither of which match the regex for arg "name". "\w+" matches 1 or
more wor
be the best approach
> to build these "widgets" for use on multiple pages? Any help would be
> much appreciated. Thanks.
Custom Template Tags?
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#howto-custom-template-tags
--
Norman J. Harman Jr.
Senior Web Specialis
Charles Choiniere wrote:
> On Mon, Sep 22, 2008 at 10:46 AM, Norman Harman <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> nek4life wrote:
> > How would I go about getting a queryset into an include? Say I
> have a
> >
ecimal import Decimal, ROUND_HALF_UP, ROUND_HALF_DOWN
>
> With this >> ImportError: cannot import name MetaData
>
> Full trace: http://paste.pocoo.org/show/85970/
>
>
> Thanx again!
>
>
It looks like you have made a circular import:
statemachine imports myfunct
environment has a proj_settings.py that imports
proj_base_settings.py and overrides whatever is required. This is often
just setting DEBUG, email addy, and db. This file is not checked into
source control.
I prepend proj_ to all the settings files so I can have multiple
projects in same python
e syntax would be this.
permission = Permission.objects.get(name="in_artist_pulldown")
users = permission.users.all()
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sid
to recommend to Djangonista's just
starting out.
And you forgot wsgi options ;)
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all
is there
Sorry for the screw up
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
Get off the sidelines and huddle up with the Statesman all season long
for complete high school, college and pro
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
How do I unsubscribe from this list?
Jim Norman
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkwMVVMACgkQ677kSNWvnhS3EQCeO2OguYmNhKiyywl2HqXnLslF
Hi,
request.template is None instead of what it should be because the response is
from the
cache middleware.
Which is fine. My question is there a good way to disable the cache
middleware during
tests?
"good" being atleast the following. is automatic, isn't based of value of
DEBUG, doesn
Eratothene wrote:
> I think you better not disable cache middleware in tests. If tests
> fail, so will be in production. I had similar problem, I thought it
> was something wrong with tests, but really it was problem in the code.
> My site was running well on django built-in server, but not on apa
lts) but those don't matter unless your site is
real busy.
another option parsing apache/nginx/whatever logs for whenever
particular url(s) where responded to.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
__
er(somefilter=whatever))
return HttpResponse(data, mimetype="text/javascript")
or
http://www.djangoproject.com/documentation/serialization/
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
___
roject.com/documentation/templates/#divisibleby
>
>
Wouldn't http://www.djangoproject.com/documentation/templates/#cycle be
a better solution? I think it was designed exactly for zebra tables.
--
Norman J. Harm
Why don't you use the extra_context parameter to generic views? Or am I
misunderstanding what you are trying to do?
def myview(request):
context = dict()
context["my_custom_var"] = "wwgd"
return generic_view(request, extra_context = context, bla=blah,...)
fizban wrote:
>
> On 14 Apr, 16:54, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>
>> Why don't you use the extra_context parameter to generic views? Or am I
>> misunderstanding what you are trying to do?
>>
>> def myview(request):
>>
I've never seen anything that would make this "easy" in Django itself.
You will probably have more luck looking into sql proxies. Django will
talk to the proxy, the proxy will figure out what database to actually
query and return results to Django. This way Django doesn't have to
change, do
seems to me that the presentation
> and logic are located on the same server for Django applications.
>
>
Have you looked at PEAK Python Enterprise Application Kit
http://peak.telecommunity.com/
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Gro
iews and their
variations.
Not exactly what you are asking for but I find it better to fail
unittests than throw exception at runtime.
Alternatively or in addition you could set your production settings.py
to something like,
TEMPLATE_STRING_IF_INVALID = "this is a bug please email
[EMAIL
the process of parceling out a bunch of models myself. Don't
> give yourself that headache!)
If you are distributing apps separately you can use conttenttypes and
generic relations.
http://www.djangoproject.com/documentation/models/generic_relations/
django-tagging django-voting are s
h:
>
> in my models, a model object is only aware of the objects above it,
> and not below it.
> in C, i remember i just declared all functions, with no body to it, at
> the top of the file
> then all functions were aware of all functions.
> how do i d
ative is to pass in a context var that already has the list you
want.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print
t* want to
set this on for production code(large performance penalty).
PythonAutoReload On
I'm guessing mod_wsgi and others have something similar.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
Any suggestions?
The standard http://www.djangoproject.com/documentation/csrf/ CSRF
protection middleware does something like that.
Don't know details but could look there.
If you're gonna 1way hash things such as 'id' and worry about speed then
store the 1way hashed value in dat
how
many records you have.
http://www.guardian.co.uk/world/2006/jul/20/secondworldwar.tvandradio
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! I
one:
self.hash = self._generate_hash()
And queries are:
chapter = Chapter.objects.get(hash="wolewadu")
Definitely make it indexed column though.
The business case is different from what I think Mike wants b
one:
self.hash = self._generate_hash()
And queries are:
chapter = Chapter.objects.get(hash="wolewadu")
Definitely make it indexed column though.
The business case is different from what I think Mike wants b
Graham Dumpleton wrote:
> On May 16, 12:21 am, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>> Alex Morega wrote:
>>> On May 15, 2008, at 02:24 , David Zhou wrote:
>>>> Are you restarting the server between module changes?
>>> By default
not the reason, and if you really wanted to you could mix your
app code and templates, by setting TEMPLATE_DIRS.
None of your django code, templates, settings etc needs to be accessible
via browser nor should it be.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Au
n_count += 1
self.save()
Then from your view call it
def adopt_bunny(request, id):
bunny = get_object_or_404(Bunny, pk=id)
bunny.adopt()
return single_bunny(request, id, True)
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
s something else going on.
I would add print statements to determine what is in fact happening.
for row in reader:
try:
b = OrderEmail(name=row[0], email=row[1], been_sent="0")
b.save()
print "saved", row
except Exception, msg:
Greg wrote:
> Norman,
> I added those print statements and ran the script. The output was
> this over and over again:
>
> ///
>
> current transaction is aborted, commands ignored until end of
> transaction block
>
> //
>
> Any suggestions?
It sounds
fetch from
database and store in cache with expiration of 24 hours.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In p
[EMAIL PROTECTED] wrote:
>
>
> On May 22, 12:11 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>> I don't know if this is the "right" direction but I've had success using
>> memcached to implement of the day items.
>>
>>
blog: %s" % entry.title)
return {"featured_blog_html": html}
except Entry.DoesNotExist:
pass
def index(request):
context = RequestContext(request)
get_featured_blog_context(context)
get_featured_foo(context)
get_featured_bar(context)
ret
'mykey')
Sounds like you have caching disabled or are using something like
dummycache. Are you sure memcached is running?
Reread
http://www.djangoproject.com/documentation/cache/#setting-up-the-cache
--
Norman J. Harman Jr. 512 912-5939
Techn
and updated a
times_viewed field in the models.
Scaling that to more than one machine adds complexity. I'd probably
pursue a different solution when/if traffic warranted it.
--
Norman J. Harman Jr. 512 912-5939
Technology Solutions Group, Austin American-Statesman
__
is and how it
should be formated. Users are more likely to know about changes to
their countries addressing scheme. Etc, etc.
With that in mind the best way to handle varying international addresses
is with a largish char column backend and multiline text input box on
frontend.
--
Norman J
000
The spaceless tag helps sometimes, but not for your situation.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun! Check out Austin360.com for all the entertain
.session['m_key'] but I get an error that session does not have
> 'm_key' key.
I've spent a lot of time debugging session problems only to discover I
had made the bone headed mistake of having this settings combo
CACHE_BACKEND="dummy://"
SESSION_ENGINE=&quo
h Django is
http://superjared.com/entry/real-problem-django/. I didn't mean to
sound complainy in previous post, if anyone took it that way.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
__
elf._calc_value()
super(FooModel, self).save()
def test_value_on_save(self):
test_data =( (dict(foo="", bar=""), 42 ),
(dict(foo="1", bar="3"), 37 ),
# test more edge cases, etc.
to
use something like urllib2 and POST to 3rdpary in your view code, slurp
the response and send it back to user. It will have 3rdparty content
but come from your server, which is probably gonna cause problems.
--
Norman J. Harman
omething else is wrong ;)
btw hard coding a path "C:\dev\incidents\admin_media" in your
urlpatterns is probably a bad thing to do. As whoever uses your
app/where ever you deploy it for production is unlikely to install the
app in the same place you do on your dev machine.
--
Norma
> What about uniqueness, and composite field uniqueness?
> # unique_together = (("field1", "field2","field3"),)
>
> I'm thinking it would make sense to try to
> create 2 of an object and save them, and check that it fails
Yep two of the objects whose 3 fi
ues()
If order is important:
list_o_dicts = [ dict_that_should_be_list[k] for k in
sorted(dict_that_should_be_list.keys()) ]
Then you can use the template for loop construct normally
{% for dict in list_o_dicts %}
{{ dict.post }} {{ dict.title }}
{% endfor %}
--
Norman J. Harman Jr.
_suggestion = False
def reject(self):
assert self.is_suggestion
# not sure how to delete relation
# self.suggestion.suggestion = None ???
self.delete()
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
et the dynamic urls to work.
url(r"^$", site.root, name="ts_admin",
kwargs={"url":"specials/adspecial"}),
Actually, I'd really love to learn a cleaner way to d
Brian Rosner wrote:
> Hi Norman,
>
> On Jun 17, 2008, at 3:49 PM, Norman Harman wrote:
>
>> I want to use {% url %} to point into portions of the admin site(and
>> change the default url structure). I hacked this generally
>> unfullfilling but working version w
a more Django way of doing it
> than me doing it manually.
http://www.djangoproject.com/documentation/db-api/#range
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun! Check
This is what I'm talking about
http://www.djangoproject.com/documentation/model-api/#unique-for-date
Searching internets can not find any answer.
Thanks,
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Stat
primarily developing in Python,
which was pretty hard to find not so long ago.
Lately I've been answering what questions I can on this forum. Which is
my preferred way of saying "thanks". I wish it was easier to contribute.
--
Norman J. Harman Jr.
Senior Web Specialist,
return render_to_response("mytemplate", extra)
see http://www.djangoproject.com/documentation/shortcuts/#render-to-response
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You
e know what my template should contain to achieve admin look
> and feel.
look in django/contrib/admin/templates
extending admin/base_site.html is what I believe you want.
--
Norman J. Harman Jr.
Senior Web Specialist,
path every time
/usr/local/python2.5/bin/python setup.py install
or you can use an alias (I suggest adding to your .bashrc or similar file)
alias python=/usr/local/python2.5/bin/python
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
__
to work.
Other options would be putting them in a ChoiceField and using Select
(dropdown) RadioSelect (radio buttons) or some custom widget.
The choice field options will have only one delete button but require
user to select which record to delete. That may or may not be a better
ui than
model-api/#relationships
to_field The field on the related object that the relation is to. By
default, Django uses the primary key of the related object.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
t; root
url.
If so, I would determine this in the view and pass in a template
varible, 'is_root'. But I don't think wrapping an extends in a if/endif
will work.
Or do you mean the template is root as in it doesn't extend any other
templates.
In that case just skip the if/
e state in a stateless server, use persistent
storage like a DB.
There *are* two or more copies of the global. There are as many copies
as WebFaction runs instances of django (mod_python or whatever)
It works in dev cause manage.py runserver only starts one instance of
django.
--
Norman J. Har
create my own field,
NullCharField or NullIntegerField that replaces "" or None with NULL
according to the null=true parameter.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You'v
at
programmer".
btw, I really think IntegerField is the wrong column type for a zip
code. They can be upto 11 chars long and have hyphens. I'd make it
CharField or maybe even a USZipCodeField from
'contrib/localflavor/u
tatus_code=302,
target_status_code=200)
http://www.djangoproject.com/documentation/testing/#assertions
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun! Check out Austin360.com for all the
There are reasons the
HTTP Internet has exploded in a way client server never did.
From my understanding of Comet it's more or less exactly what you are
asking for. http://www.google.com/search?q=django%20comet
--
Norman J. Harman Jr.
Senior Web Specialist,
Django developers and community to maintain multiple stable branches.
Compare Django release discipline and record to other major frameworks.
And your PHB's should be scared to use anything but Django.
--
Norman J. Harman Jr.
Senior W
blogs by the same author then there are 10 hits on
user_profile to read it each time.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun! Ch
Alex Koshelev wrote:
> Or may be a custom template tag for common stuff.
Or like any code anywhere just extract the common parts to a helper
function and call that.
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-States
w
> functions.
Test system creates a new test database from scratch every time it is
run. manage.py loaddata has NO effect on test.
I could be wrong but I don't believe test runner automatically loads the
fixture initial_data.xml
You need to tell it what fixtures to load
1 - 100 of 128 matches
Mail list logo