I think that is not the best solution.
As i understand you are ordering only displayed items because of
pagination
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send emai
You can use ordering by primary key (id by default) because it
increments by every insert.
So newly created rows in db will have greater id than others.
In most cases it can be enough.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to th
> ..go back and read the original poster's
> message. Having the user in threadlocals doesn't solve any problem,
> since he's trying to create a form class based on information in the
> request and that only happens at import time, not every time something
> in the file is looked at.
Yes, my mista
Why do you think so?
--~--~-~--~~~---~--~~
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
django-users
You can also use threadlocals middleware (ask google about it =))
to get current user without request object
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to d
from datetime import date, timedelta
a = date.today() - timedelta(7 * 12)
print a
2009-05-13
--~--~-~--~~~---~--~~
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@goog
try
http://docs.djangoproject.com/en/dev/ref/settings/#file-upload-max-memory-size
--~--~-~--~~~---~--~~
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
Why not?
You can simply specify mimetype in HttpResponse object
urls.py
(r'^articles.xml/$', my_view_function, {'format': 'xml'}),
(r'^articles.html/$', my_view_function, {'format': 'html'}),
views.py
def my_view_function(request, format='json'):
if format == 'xml':
mimetype = '.'
You need to ensure that key exists:
if request.POST.get('Lived_Out_Uk', '0') == '1':
.
--~--~-~--~~~---~--~~
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@googl
It's difficult to even imagine such query (possible but very
inefficient),
i think you need to change your architecture
or do this grouping in bussines layer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django use
Why do you need admin here?
You can generate it in the save() method of your model.
--~--~-~--~~~---~--~~
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
or there is another way.
create custom command for manage.py
(http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
#howto-custom-management-commands)
it's pretty simple.
then write bash script like this:
#!/bin/bash
export PYTHONPATH=/path/to/django
cd /path/to/project
python man
I guess you are using SSH?
so before running your script run:
export PYTHONPATH=/path/to/django
hope this helps
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email
You need to use raw sql. (http://docs.djangoproject.com/en/dev/topics/
db/sql/#topics-db-sql)
I don't understand what will be if there are more then 2 channels at
the same datetime?
So i can't provide you solutions sample.
--~--~-~--~~~---~--~~
You received this me
Use extra() method of query set with little hack ;)
mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP
(bbs_tag.name, 'notice'), '',bbs_tag.name)'},
order_by=['ordering_field'])
--~--~-~--~~~---~--~~
You received this message because you are subscribed to t
Yes, it is possible.
try this http://code.google.com/p/django-ajax-filtered-fields/
I usually write this stuff by myself, so if this solution does not
works for you,
i can provide my.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
Look at
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls
It will be like this:
from django.core import urlresolvers
my_url = "%s?tender__id__exact=%s" % (
urlresolvers.reverse('admin:tender_download_changelist'),
self.id
)
--~--~-~--~~--
try:
url(r'^keyword/modify/(?P\d+)/$', 'klucoveSlovo_update', name =
'keyword-modify'),
--~--~-~--~~~---~--~~
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@google
And do you want to avoid
'django.template.loaders.app_directories.load_template_source' ?
It will work only when your template will not be found in default
template directory
So i guess there is no overhead when you use it in production.
May be you have DEBUG=True in your development version and
And what about other custom tags?
I actually have no more ideas, what it can be.
--~--~-~--~~~---~--~~
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.co
Read documentation
http://www.djangoproject.com/documentation/models/pagination/
--~--~-~--~~~---~--~~
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
I my case custom tags are still working after i removed
''django.template.loaders.app_directories.load_template_source'' from
settings.
You can see comment in site-packages\django\template\loaders
\app_directories.py:
"""
Wrapper for loading templates from "templates" directories in
INSTALLED_APPS
No, this settings
'django.template.loaders.app_directories.load_template_source'
means, that django will look for templates( not tags ) in each(!)
application you have in INSTALLED_APPS
(if application folder has folder 'templates' ).
On Jul 28, 11:23 pm, chefsmart wrote:
> Is 'django.template
def __init__(self, *args, **kwargs):
super(ShippingMethodForm, self).__init__(*args, **kwargs)
if self.fields['country'].initial == 'Canada':
filter_kwargs = { 'delivery_time__lte': time_avail_hours,
'abbrev__contains'='SC' }
elif: ...
else: ..
self.fi
There is a very good solution for tagging
http://code.google.com/p/django-tagging/
try this, it will save you a waste of time
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this grou
You are welcome ))
--~--~-~--~~~---~--~~
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
django-users+u
not magic))
incorrect settings.
make sure that all required javascript is avaliable.
--~--~-~--~~~---~--~~
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
Look into your settings again.
I've had such problem before.
After some magic with settings everything works.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
Sphinx
Here samples http://softwaremaniacs.org/blog/2007/11/04/sphinx-search-in-cicero/
(but in Russian)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to djang
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
here is a sample how to handle file upload
And have tried:
MyForm.save()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post t
class MyForm(...):
def __init__(self, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['myfield'].choices =
City.objects.values_list('id', name_field)
--~--~-~--~~~---~--~~
You received this message because you are subscr
I'm writing custom session based wizard (data between step is stored
in sessions).
One of the steps is uploading files (not the last).
The problem is that i save models only after last step.
So the question is how to deal with files?
As i understand there is no way to store files in session
--~-
> I am working on a search form that has a SelectMultiple widget. What
> would be the best way to make a complex lookup with the SelectMultiple
> widget?
try this:
try:
district_ids = [int(x) for x in request.GET.getlist('district')]
if len(district_ids) == 0:
district_ids = [
You can define image upload path at runtime (check manual for
ImageField)
def get_photo_path(instance, filename):
return 'static/upload_to/photos/%s' % instance.name
class ProductImage(models.Model):
name = models.CharField(max_length=50)
file = models.ImageField(upload_to= get_photo
You can also try this:
or_query = Q()
if places:
or_query = or_query | Q(persplace__icontains=places)
if names:
or_query = or_query | Q(persname__icontains=names)
results = Person.objects.filter(or_query)
--~--~-~--~~~---~--~~
You received this
Take a look at http://code.google.com/p/django-profile/
--~--~-~--~~~---~--~~
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
Code above was a bit incorrect. Here better solution:
## widget declaration
from django.utils.safestring import mark_safe
from django.forms.widgets import FileInput
class AdminImageFieldWithThumbWidget(FileInput):
def __init__(self, thumb_width=50, thumb_height=50):
self.width = thum
Sorry, it was my mistake about:
> content_type = ContentType.objects.get_by_id(p.contenttype_id)
Try this:
> content_type = ContentType.objects.get_for_id(p.contenttype_id)
About overriding save() method see
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-method
First of all about ContentTypes:
For example in your Page table you have 2 lines.
One is PageText, another PageGallery.
So you have 2 different ContentTypes.
How to determine type of Page:
p = Page.objects.get(id='main')
#here we get ContentType object for PageText or PageGallery
content_ty
If you want to have some hierarchy for you pages, look at django-mptt,
but
with this inheritance type (non abstract) it works not correct (I have
added some changes to it to support this)
another way i describe below.
If you don't need hierarchy, so simple add 'order' field to Page
For hierachy:
You can also inherit you GalleryPage and TextPage from your Page (not
Abstract).
Add content_type field to your Page. So it's easier to determine page
by it's id,
when i will write views.
After that register in admin only TextPage and GalleryPage.
Hope this helps
--~--~-~--~~
Set collation to utf-8
I had the same problem with Russian until i change collation for all
char field in my DB to utf-8
and default collation for DB
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" gr
I have written some sample.
it works for me, hope it will be usefull:
from django.contrib.admin.widgets import AdminFileWidget
from django.utils.safestring import mark_safe
class AdminImageFieldWithThumbWidget(AdminFileWidget):
def render(self, name, value, attrs=None):
thumb_html =
Full example here
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIchangetheattributesforawidgetonafieldinmymodel.
class MyModelAdmin(admin.ModelAdmin):
...
def formfield_for_dbfield(self, db_field, **kwargs):
field = super(MyModelAdmin,
self).formfield_for_dbfield(db_fiel
Thanx, works perfectly!
--~--~-~--~~~---~--~~
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 [EMAIL PRO
I have model with 3 fields - id, name_ru, name_en
I want rename 'name_ru' field to 'name' in query
i try this:
operations =
OperationType.objects.values('id').extra(select={'name': 'name_ru'})
but it returns only 'id'
what's wrong??
--~--~-~--~~~---~--~~
You
I use same django instalation for several projects,
so it will cause other projects works incorrectly.
Any way, thank you for advise
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to thi
unfortunately i'm not Moldavian-speaker =((
outsourcing =))
So as i understood the only solution is to write middleware, to change
locale dynamically
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" grou
I think you need to write custom widget for ImageField
--~--~-~--~~~---~--~~
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 th
I have Django site in 2 languages - Moldavian(default) and Russian
But django-admin is not localized for Moldavian, that's way i want to
use Russian in admin.
So my settings.py will look like this:
LANGUAGE_CODE = 'md'
LANGUAGES = (
('md', (u'Moldavian')),
('ru', (u'English')),
)
But dj
Add extra variable to the context in this way:
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowcanIpassextracontextvariablesintomyaddandchangeviews
then override your submit_line.html template and put into it something
like that:
{% if my_show_delete_link %}
{% if show_delete_link %}{% tran
You can also try django-mptt,
that works great with object hierarchy
http://code.google.com/p/django-mptt/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to dj
make sure that you use Django 1.0
this mechanizm was changed since 0.96
--~--~-~--~~~---~--~~
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 unsub
So you can add context variable in your tag and check it in template
{%if my_tag_js_not_added %}
alert();
{% endif %}
...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to t
you can add JS not only inside
--~--~-~--~~~---~--~~
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 [E
You can create only one model with empty 'other' field.
If you could create one more, field 'other' will not be unique more.
That's why validation fails.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django u
I do it in the same way. I think there is no need here make here
something more complex
--~--~-~--~~~---~--~~
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@googlegro
sorry, you need
story = Story.objects.filter(pk=1).extra(select={'main_section':
sub_select }).values('main_section', 'other_field1', 'other_field2' )
[0]
because we get here list of dictionaries
Good luck!
--~--~-~--~~~---~--~~
You received this message because
You can use an extra select to get additional parameter 'main_section'
This is for MySQL and it's only sample
you need to test it in your DB to make sure, that it works
sub_select = """SELECT section_name
FROM %(table_section)s as sc, %
(table_section_story)s as st
Use filter "safe" in your template:
{{ mymodel.page|safe }}
--~--~-~--~~~---~--~~
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
I still think you need second query.
as i understand from your code get_main_section will return list of
Sections in Story?
I mean this string:
(section_name = self.id_section.all().order_by('order') )
bad:
if (len(self.id_section.all()) > 1):#hits DB
section_name = self.id_section.
it seems you need extra select anyway
or use .extra(...) to add additional args to db query
(http://www.djangoproject.com/documentation/db-api/#extra-select-none-
where-none-params-none-tables-none-order-by-none-select-params-none)
But i don't understand. Imagine we have Story with 3 Sections
And
Solution #1:
use select_related() method when you get your Story from db:
Story.objects.get(pk=3).select_related()
Solution #2:
add to your Section class definition method:
def __unicode__(self):
return self.section_name
and change your template to:
{{ story.id_
try this:
>>get_models(arteak.management.models)[0]._meta.verbose_name_plural()
--~--~-~--~~~---~--~~
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
I'm still using threadlocals. It's more convenient for me.
--~--~-~--~~~---~--~~
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
> There is no longer any reason whatsoever to use this in any way in the
> admin. It was an ugly, fragile hack before and it's unnecessary now
> because ModelAdmin has a get_form() method -- which receives the
> HttpRequest object as an argument -- that you can override to tweak
> the form on a pe
On 24 авг, 23:56, "Patrick J. Anderson" <[EMAIL PROTECTED]>
wrote:
> How should I limit choices for ForeignKey fields in admin.ModelAdmin
> instances based on request.user attributes, since I can't pass a request
> object to the forms.ModelForm constructor?
You can use ThreadLocals middleware
ht
67 matches
Mail list logo