I made what I wanted in
def log_deletion(self, request, object, object_repr):
It's not elegant, but in Django 1.3 there is a delete_model() function:)
But now I'm using 1.2.4 :)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this gr
How can I override slugify function globally? I want to add some other
letters actions especially form my language.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscri
Is there any way to get the full path of file, which will be uploaded?
in save_model action i can get obj.image but it gives me only the file name.
I want to get path with upload_to from model.
Is it possible?
I need it, because I want to make resizing on my image and make its name
with hash to
I try to create thumbnail via PIL
import Image
ARTICLE_LARGE_SIZE = 230,300
tmp_file = Image.open(form.cleaned_data['image'])
tmp_file = tmp_file.thumbnail(ARTICLE_SMALL_SIZE)
tmp_file.save(location + '/small.jpg', 'JPEG')
I get: 'NoneType' object has no attribute 'save'
WTF?
When i replace tmp_f
Thanks. It works great :)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more opti
I get another strange error - this time only while adding article. In
editing all is fine.
def save_model(self, request, obj, form, change):
if change == False:
obj.save()
if ('image' in form.changed_data) or (change == False):
tmp_file = Image.open(form.cleaned_data['image'])
It gives me
Is it possible to set DateTimeField in model to be empty?
I don't want to set it when adding it to database but edit it in future.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.co
I tried but I get:
Exception Type: IntegrityError Exception Value:
(1048, "Column 'publish_date' cannot be null")
Exception Location: C:\Python27\lib\site-packages\MySQLdb\connections.py in
defaulterrorhandler, line 36
Field definition: publish_date = models.DateTimeField(editable=False,
bla
Yes, I had to remove and make syncdb for that table. All works fine now :)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-
Hi,
im my model I have a field title as unique.
Adding new records works fine. But when I want to edit it, I get problem.
Here's the code:
view:
article = Article.objects.select_related().get(pk=id)
if request.method == 'POST':
form = ArticleForm(request.POST, instance=article)
I try to redirect from 404 view to my index page. In url.py i added:
handler404 = 'index.views.custom404'
in my index i have:
def custom404(request):
return HttpResponseRedirect(reverse('index'))
But it doesn't work.
Should I do something more?
--
You received this message because you
Yes I have a index pattern:
urlpatterns = patterns('',
url(r'^$', 'index.views.index', name='index'),...
When I add print to my method:
def custom404(request):
print 'foo'
return HttpResponseRedirect(reverse('index'))
It prints out but it doesn't redirect me to index. Instead it d
When I try to insert that string to urlfield: http://asd[d I get strange
exception:
Invalid IPv6 URL
How to correct it to show message and not error 500?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to d
Django 1.2.4,
Python 2.7
All is coded as it should be. debugger shows error in python code as You
said. Maybe it will be fixed in the future. Exception is only when i put [ .
When i put [] all is ok :)
--
You received this message because you are subscribed to the Google Groups
"Django users"
How can I put a file, which is needed by the Google Webmasters Tool? Where
to put it or how to configure django to read it?
--
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 u
ModelForm:
class ArticleForm(ModelForm):
title =
forms.CharField(widget=forms.TextInput(attrs={'class':'input_visible_title',
'title' :
_(u'Tytuł'),}), max_length=255, min_length=3)
content =
forms.CharField(widget=forms.Textarea(
I can't find out how to pass corrent location to the sitemap element.
I have declared:
def items(self):
return Category.objects.all()
How can i generate my correct urls from my urlconf file:
url(r'^category/(?P[\w\-_]+)/$', 'show_category',
name='show_category'),
I have no idea hot to do
To precise:
I have 2 models:
class Job(models.Model):
name = models.CharField(max_length=150, unique=True)
slug = models.SlugField(max_length=150, unique=True)
class JobType(models.Model):
name = models.CharField(max_length=150, unique=True)
slug = models.SlugField(max_length=150,
I use NetBeans and it's OK :)
--
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+unsubscr...@googlegroups.com.
For more
Hi,
how can I assign a default siteID to my flatpages during saving it?
I use only 1 Site and want to attach ID=1 to each added flatpage
--
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@googlegrou
I found that link:
http://linfiniti.com/2011/01/bending-django-flatpages-to-your-will. I want
to make some customization in flatpage. Where should I put this extra module
and form?
I want to add 2 fields to custom flatpage.
--
You received this message because you are subscribed to the Google
Should I alternate original flatpage midddleware?
If I won't do that, my new fields can be unseen?
--
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
Is it a good idea to import modules in the middle of the code, and not on
the beginning?
I want to make a hash generation. It's few lines - it's used once in all
application. Should I import hashlib just on the beginning of the file? Now
I put it with the rest of the code.
Is it bad?
I don't wa
Hi,
I'm building register form using UserCreationForm.
I have simple form:
class RegisterCustomerForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(RegisterCustomerForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
self.fields['em
My django runs on FastCGI as I can see.
I have that small part of the code:
# Generate user register_hash
import hashlib
reg_hash = hashlib.md5()
reg_hash.update(request.POST.get('email') +
str(random.random()) + request.POST.get('username'))
At the top of the file pase:
# -*- coding: utf-8 -*-
In declaration of text that contains utf8 make it in that way:
help_text = u"dádá español"
of course set file encoding to utf8 :)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post
Is it possible, to add some extra validation checks
into django.contrib.auth.views.login?
I need to check some fields from UserProfile to login
--
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@go
Is there any working toolbar for Django 1.3?
https://github.com/dcramer/django-debug-toolbar - this doesn't work in my
project based on 1,3 :/
--
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@goo
It doesn't work when I switch on the panel for SQL
('debug_toolbar.panels.sql.SQLDebugPanel',). Without that panel it works.
That's error:
TemplateSyntaxError at /
Caught AttributeError while rendering: 'Cursor' object has no attribute 'db'
Request Method:GETRequest URL:http://localhost:8000/Dja
I run my sever on localhost (manage.py runserver).
Is there any way to display all queries in console or somewhere else?
--
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
Thanks, I'll try it :)
--
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+unsubscr...@googlegroups.com.
For more options
That helped:)
New checkout fixed the problem :)
--
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+unsubscr...@googlegro
Is it possible to make value of LOGIN_REDIRECT_URL from my urls.py? I don't
wan't to hardcode it.
I don't want to pass next in my url. Maybe there is another way to redirect
to my reverse('index')?
--
You received this message because you are subscribed to the Google Groups
"Django users" grou
Is it possible to pass request.path in urls.py? I want to pass it as next
parameter in logout declaration.
--
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
is it possible, to deny access to django.contrib.auth.views.password_reset
for users who are authenticated?
I want to use it, and make it only for not logged in.
I can't figure out how to do that. I have done all things with reset, but
all users can enter it:/
--
You received this message beca
What is the best way, to select X random rows from DB? I know that
method: .all().order_by('?')[:X] is not good idea.
What methods do you use?
--
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@goo
If i knew what is a good idea, I wouldn't aks here:D
I only know - that described method is DB killer :)
--
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
I use extended UserProfile. Now I want to make a profile edition. I need to
place all my custom profile fields and email, firstname, lastname from
original User model.
I try to do this, but can't make it work. Email field is not shown. None of
the User model are shown.
My forms:
class MainUser
I need to do this in my tagcloud.
--
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+unsubscr...@googlegroups.com.
For m
I need to skip translating some content from the string in template.
I want to make something like this:
I pass the tag variable to the temaplte. Then I want to make a string: Tag:
tag_variable. I need it to be in trans block, but only first word (Tag) must
be translated. In other words - I need
I need to make a form, which have 1 select and 1 text input. Select must be
taken from database.
model looks like this:
class Province(models.Model):
name = models.CharField(max_length=30)
slug = models.SlugField(max_length=30)
def __unicode__(self):
return self.name
It's row
Thanks, that's the way I'll do it:)
But now I have 1 more problem. In ModelForm I want to get some data about
user from DB. I nedd to filter user provinces. How canI call the user id in
my query? I pass request.user as form instance in view: form =
ProvinceForm(instance=request.user)
How to rea
I made it that way but i get empty select list
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces =
UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('provi
hmm, that solutoin works great:)
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces =
UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('province')
s
Now I have some strange thing. I display my form, send post and try to save
it. But it doesn't save:/
Here's my code:
model:
class UserProvince(models.Model):
user = models.ForeignKey(User)
province = models.ForeignKey(Province)
class Meta:
unique_together = (('user', 'provinc
I think it works. Thanks. What I did:
changed the form cal in view:
form_provinces_to_add = ProvinceForm(request.POST, user=request.user)
changed a form a little:
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(ProvinceFo
I'm thinking how to display forms in that configuration:
I have 3 simple models:
class Province(models.Model):
name = models.CharField(max_length=30)
slug = models.SlugField(max_length=30, unique=True)
class UserProvince(models.Model):
user = models.ForeignKey(User)
province = mode
Why old file is not deleted if I want to change it? I select new file in
form and it's saved but old file is not deleted. Is it my fault or Django is
designed not to delete it (if so, how to delete old file)?
--
You received this message because you are subscribed to the Google Groups
"Django
Models:
class Technology(models.Model):
name = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=100, unique=True)
class Site(models.Model):
name = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=100, unique=True)
I use select_related().
How to apply it with regroup? I haven't use it before.
--
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
dja
In template in main loop I want to display all technologies assigned to the
each site. Technologies are assigned by m2m relation. So I run subloop as
You can see in code above. I want to reduce the number of queries executed
by those subqueries. I want to know, if there is a better way to do thi
1. I'm wondering if I can delete a cached content made in template cache. I
want to delete it from my view. I have in my template {% cache 500
cache_name sites.number %}
Is it possible to delete all "cache_name" cached content within the view,
for example when some action is made?
2. I want to
Anyone can help me with that error?
--
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+unsubscr...@googlegroups.com.
For
I know how to create cache and delete it. But - how can cache and then
remove cached content based on pagination. Now my caches are named result-1,
result-2, .
How in 1 line can I delete all paginated content?
--
You received this message because you are subscribed to the Google Groups
"Dj
That's nice. I must check it.
--
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+unsubscr...@googlegroups.com.
For more
Hi, I have defined delete() method in my model. I use it to clear cache and
delete thumbs. When I delete an element in admin, in it's details (edit
mode) cache is cleared and all thumbs are deleted.
But, when i want to delete several elements at once - checking checkboxes on
the elements list -
So if I'll define delete_model in admin - it will work?
--
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+unsubscr...@g
57 matches
Mail list logo