Models inside tests - Django 1.7 problem

2014-09-04 Thread galgal
Hi,
I'm trying to port my project to use Django 1.7. Everything is fine except 
1 thing. Models inside tests folders.
Django 1.7 new migrations run *migrate*  command internally. Before *syncdb 
*was ran. That means if a model is not included in migrations - it won't be 
populated to DB (and also to test DB). That's exactly what I'm experiencing 
right now.

What I do is:

   - In my /app/tests/models.py I have dummy model: class TestBaseImage(
   BaseImage): pass
   - All it does is to inherit from an *abstract **BaseImage* model.
   - Then in tests I create instances of that dummy model to test it.
   
The problem is that it doesn't work any more. It's not included in 
migrations (that's obvious as I don't want to keep my test code in 
production DB). Running my tests causes DB error saying that *table does 
not exist*. That makes sense as it's not included in migrations.

Is there any way to make it work with new migrations system? I can't find a 
way to "fix" that.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2236bfb7-7676-4caf-a6b1-9438ec5bba93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Mock Django FileSystemStorage location?

2014-04-08 Thread galgal


I try to mock FileUpload in django view (admin view).

My model looks like that:

class BaseImage(models.Model):
# create path for uploaded images
_storage_path = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'secure_media'))
_image_storage = FileSystemStorage(location=_storage_path)

image = SorlImageField(
verbose_name=_(u'image'),
storage=_image_storage,
upload_to="%Y/%m")

class Meta:
abstract = True

and test:

def test_add_new_as_main(self):
url = reverse('admin:galleries_secureimage_add')

post_data = {
'image': get_temporary_image()
}
response = self.client.post(url, post_data)

This uploads file to directory specified in _storage_path and I want to 
change that in my test.

How can I mock _storage_path to return different path in my tests? I tried 
to use Mock() library but can't make that work.

Can you help me?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8bcd2578-b9a9-4662-97ff-7867c88f2829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to divide my apps? Good practices?

2013-06-23 Thread galgal





I've made a quick schema of couple of main tables. As you can see, there 
are many relations, so I think putting it all in one app. There will be a 
couple of additional models. There will be 1 more thing: a play systems. 
Some seasons can have simple table games but others - of example 2 rounds 
of regular matches etc... That will be a special, separated class for that, 
in the same app as rest I think.

What do you think?


-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to divide my apps? Good practices?

2013-06-22 Thread galgal


I've made a quick schema of couple of main tables. As you can see, there 
are many relations, so I think putting it all in one app. There will be a 
couple of additional models. There will be 1 more thing: a play systems. 
Some seasons can have simple table games but others - of example 2 rounds 
of regular matches etc... That will be a special, separated class for that, 
in the same app as rest I think.

What do you think?


<https://lh5.googleusercontent.com/-qOLlE17nHSg/UcY7Lmq4r5I/PQY/Xmb7QGhEqBA/s1600/test.png>


On Thursday, June 20, 2013 11:01:30 PM UTC+2, galgal wrote:
>
> Hi,
> I'm starting my new project. It's sport-connected.
> The main part of my app will be league, matches, teams and players. There 
> will be many relations.
>
> So, how to make apps and models. I plan to make models:
>
>- Season
>- League (FK to Season)
>- Team
>- Match (FK to League and 2FK to Teams)
>- Players (FK to Team)
>- and many more to present teams history in each season etc.
>
> Is it better, to make it all in 1 app, called for example Game, or divide 
> it into smaller apps?
> Thanks for help.
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to divide my apps? Good practices?

2013-06-21 Thread galgal
But I can see now that there will be a massive amount of models. Each player 
should have his own statistics for each games, there will also be a part for 
referees. Referee work will be rated by users so - many models is planned. If I 
put it in one app, I will have at least 15 models in it and I think it will 
increase in some time

Division in my example will clarify it, for example players app with all models 
for players like player base, player in season, player statistics and of course 
all logic in it.

In 1 app there will be a many many lines of code and after some time it will be 
hard to develop I think.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to divide my apps? Good practices?

2013-06-21 Thread galgal
@Mayukh Mukherjee yes, I have that in mind. That's why I'm asking about 
it:) I'm confused now and need any advice if that all models should be in 1 
app, or in couple of apps.

I'm rather convinced to make couple of apps

   - teams (models with teams - at least 2 models. team as global in my 
   app, and team in the season (its name, etc))
   - players (the same as above)
   - leagues with different competitions systems
   - etc...

It should be better in future to develop new features.

On Friday, June 21, 2013 3:30:48 PM UTC+2, Mayukh Mukherjee wrote:
>
> Just some generic advice -- keep each app focused on one individual 
> task,as a rule of thumb you'd want maybe 5 +/- 2 models per app. Better to 
> have multiple apps that each do one thing well than one large app that does 
> everything.
>
>
> Best
>
>
>
> On Thu, Jun 20, 2013 at 5:01 PM, galgal <weglare...@gmail.com
> > wrote:
>
>> Hi,
>> I'm starting my new project. It's sport-connected.
>> The main part of my app will be league, matches, teams and players. There 
>> will be many relations.
>>
>> So, how to make apps and models. I plan to make models:
>>
>>- Season
>>- League (FK to Season)
>>- Team
>>- Match (FK to League and 2FK to Teams)
>>- Players (FK to Team)
>>- and many more to present teams history in each season etc.
>>
>> Is it better, to make it all in 1 app, called for example Game, or divide 
>> it into smaller apps?
>> Thanks for help.
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Mayukh Mukherjee
> http://www.linkedin.com/in/mayukhmmukherjee
>
>
>  

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




How to divide my apps? Good practices?

2013-06-20 Thread galgal
Hi,
I'm starting my new project. It's sport-connected.
The main part of my app will be league, matches, teams and players. There 
will be many relations.

So, how to make apps and models. I plan to make models:

   - Season
   - League (FK to Season)
   - Team
   - Match (FK to League and 2FK to Teams)
   - Players (FK to Team)
   - and many more to present teams history in each season etc.
   
Is it better, to make it all in 1 app, called for example Game, or divide 
it into smaller apps?
Thanks for help.

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: .annotate() in limit_choices_to?

2013-05-28 Thread galgal


I wrote some code, but it returns doubled entries if there's no annotate:

price_variants = models.ManyToManyField(
ProductPriceVariant, verbose_name=_(u'price variants'),
limit_choices_to=Q(translation__language__iexact=get_language()[:2]) & 
Q(
translation__product__subproducts__isnull=False))


On Tuesday, May 28, 2013 5:44:57 PM UTC+2, galgal wrote:
>
> Is it possible to put, somehow, *.annotate()* method into M2M *
> limit_choices_to*?
> I need to limit my choices to that query:
>
> *
> cls.objects.annotate(subproducts_num=models.Count('subproducts')).filter(subproducts_num__gt=0)
> *
>
>
> Any ideas?
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




.annotate() in limit_choices_to?

2013-05-28 Thread galgal
Is it possible to put, somehow, *.annotate()* method into M2M *
limit_choices_to*?
I need to limit my choices to that query:

*
cls.objects.annotate(subproducts_num=models.Count('subproducts')).filter(subproducts_num__gt=0)
*


Any ideas?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Test limit_choices_to

2013-05-28 Thread galgal
Is there any way to test if my *limit_choices_to* argument is working as I 
expect? How can I test that in unit test?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Testing multilingual site

2013-03-11 Thread galgal
I'm making a test for a model which has a field with language.
How can I switch, using Client(), languages to test actions on various 
languages?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: TestCase - send POST with m2m data?

2013-03-09 Thread galgal
Oh, how could I miss that. Now I see it. Thanks :)

To submit multiple values for a given key – for example, to specify the 
> selections for a  – provide the values as a list or 
> tuple for the required key. For example, this value of data would submit 
> three selected values for the field named choices:
> {'choices': ('a', 'b', 'd')}


On Saturday, March 9, 2013 3:34:19 AM UTC+1, Russell Keith-Magee wrote:
>
>
>
> On Fri, Mar 8, 2013 at 7:52 PM, galgal <weglare...@gmail.com 
> > wrote:
>
>> As in the topic - how can I prepare POST data dictionary in TestCase to 
>> send it via POST?
>> I can see how it works in real admin POST in Chrome:
>>
>> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
>> Content-Disposition: form-data; name="visibly_usergroup" 1
>> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
>> Content-Disposition: form-data; name="visibly_usergroup" 2
>> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
>> Content-Disposition: form-data; name="visibly_usergroup" 5
>>
>> How to simulate that? 
>>
>
> Hi,
>
> You don't need to concern yourself about the POST data encoding -- you 
> just pass in a list of values instead of a single value to the data 
> argument in the test client.
>
> self.client.post('/your/url/here'/, data={'visibly_usergroup': 
> ['1','2','5']}
>
> This is all covered in the docs; specifically on the section on POST 
> operation of the test client:
>
>
> https://docs.djangoproject.com/en/1.5/topics/testing/overview/#django.test.client.Client.post
>
> Yours,
> Russ Magee %-)
>
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Get all objects that don't belong to M2M

2013-03-08 Thread galgal
I think that did the trick:

*Product.objects.filter(subproducts__isnull=True)*

On Friday, March 8, 2013 1:50:47 PM UTC+1, Martin J. Laubach wrote:
>
> Something like this (totally untested though)
>
> Product.objects.exclude(pk__in=Product.subproducts.through.values_list(
> 'product_id', flat=True))
>
> perhaps?
>
>   Cheers,
>
> mjl
>
>
>
>
>
>
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Get all objects that don't belong to M2M

2013-03-08 Thread galgal


I have a model with field:

class Product(models.Model):
subproducts = models.ManyToManyField("self", blank=True)

I need to overwrite admin's field queryset, to display only that objects 
that don't belong to any m2m relation. I have no idea how to get them.

So if I have: product1, product2, product3, product4.

product1 contains in subproducts: product2

I need a query that will get, in that situation, product3 and product4

Any idea how to get that?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




TestCase - send POST with m2m data?

2013-03-08 Thread galgal
As in the topic - how can I prepare POST data dictionary in TestCase to 
send it via POST?
I can see how it works in real admin POST in Chrome:

--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 1
--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 2
--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 5

How to simulate that? 

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: dynamic form fields in admin?

2013-03-06 Thread galgal
Hm, but you use 1 Form in save method. I need to show/hide/change Form 
while generating change view.
save() method is just to late for me.

On Thursday, March 7, 2013 1:51:36 AM UTC+1, Bulkan-Savun Evcimen wrote:
>
> Hi,
>
> I've done something similar just recently where I generate a "key" field 
> in a ModelAdmin to display in django admin. 
>  
>
>> from django  import forms
>> from django.contrib import admin
>
>  
>
> class MyForm(forms.ModelForm):
>> key = forms.CharField(max_length=256)
>> def __init__(self, *args, **kwargs):
>> super(MyForm, self).__init__(*args, **kwargs)
>> self.fields['key'].initial = self.instance.key
>>
>> class MyModelAdmin(admin.ModelAdmin):
>>  form = MyForm
>>  def save(self, request, obj, form, change):
>>   # save
>>   if "key" in self.form.cleaned_data:
>> del self.form.cleaned_data['key']
>>   super(MyModelAdmin, self).__init__(request, obj, form, change)
>> admin.site.register(MyModel, MyModelAdmin)
>
>
>
> In the save method of MyModelAdmin you can do your logic that you have 
> mentioned. 
>
> Hope that helps
>
>
> http://bulkan-evcimen.com
>
>
> On Thu, Mar 7, 2013 at 3:43 AM, galgal <weglare...@gmail.com 
> > wrote:
>
>> I want to make some advanced customization of admin form.
>>
>> While editing an object, I want to show, dynamically, different fields 
>> depending of 1 obj field (they are not visible while adding the obj.). 
>> There can be a situation, to validate that extra fields. For example, when 
>> object has a 'temporary' type, I must show 2 fields with dates, and 
>> validate them. If object is 'renewable' I need to show 2 different fields 
>> with different validation.
>>
>> What is the best approach to do that?
>>
>>- Make separate Form for each object type and set form attrib of 
>>ModelAdmin? If yes, in whichModelAdmin method do that (change_view()
>>?)? 
>>- Dynamically update 
>> fields<https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields>
>> in get_form() method? 
>>
>> What is the best approach to do that?
>>  
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




dynamic form fields in admin?

2013-03-06 Thread galgal


I want to make some advanced customization of admin form.

While editing an object, I want to show, dynamically, different fields 
depending of 1 obj field (they are not visible while adding the obj.). 
There can be a situation, to validate that extra fields. For example, when 
object has a 'temporary' type, I must show 2 fields with dates, and 
validate them. If object is 'renewable' I need to show 2 different fields 
with different validation.

What is the best approach to do that?

   - Make separate Form for each object type and set form attrib of 
   ModelAdmin? If yes, in whichModelAdmin method do that (change_view()?)?
   - Dynamically update 
fields
in get_form() method?

What is the best approach to do that?

-- 
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.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Relations to unknown models?

2013-01-23 Thread galgal
Hi.
I'm looking for a solution to make site-wide comments that can be connected 
with different models via FK.
I want to make 1 global model Comments. I want to make a relation to 
Articles, Relations and Solutions models. I the future I plan to add 
additional models. Now, Comments model should allow me to make relations to 
any of that models via FK. What is important, I need to have 1 and only 1 
Comments model, and it won't be abstract model.
On site I want to display stats showing how many comments were added to 
each model.

Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AhXGBGXPu_oJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb error with new 1.5rc1

2013-01-08 Thread galgal
As for my problem, I solved it by making manage.py migrate --fake 
But I don't know that is the best and good solution. So far it works somehow :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Suged2nr3fMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb error with new 1.5rc1

2013-01-08 Thread galgal
I also get strange error: 
https://groups.google.com/forum/#!topic/django-users/lVUZ3hClyUg

On Monday, January 7, 2013 10:46:18 PM UTC+1, Thiago wrote:
>
> I used auth mixin before in my app, then made the changes to make it work 
> on the official Django with new custom user.
>
> The problem is that, when I run on my new empty db:
> python manage.py syncdb --all
>
> ...
> You just installed Django's auth system, which means you don't have any 
> superusers defined.
> Would you like to create one now? (yes/no): yes
> E-mail address: e...@il.xx
> Password: 
> Password (again): 
> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>
> Do you know what is wrong?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/N6aoa9nWW9IJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Can't sync DB

2013-01-07 Thread galgal
I try to use new User model. I made my custom model, attached it 
by: AUTH_USER_MODEL = 'account.Account'
Model:

class Account(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
verbose_name=_('email address'),
max_length=255,
unique=True,
db_index=True,
)
username = models.CharField(
_('username'),
max_length=75,
unique=True,
help_text=_('Required. 75 characters or fewer. Letters, numbers and 
@/./+/-/_ characters'),
validators=[
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a 
valid username.'),
  'invalid')
])
is_staff = models.BooleanField(
_('staff status'), default=False,
help_text=_('Designates whether the user can log into this admin 
site.'))
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
date_joined = models.DateTimeField(_('date joined'), 
default=timezone.now)

objects = AccountManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']

def get_full_name(self):
# The user is identified by their email address
return self.email

def get_short_name(self):
# The user is identified by their email address
return self.email

def __unicode__(self):
return self.email


I can't sync my DB, when south is added. When I turn South off, run syncdb, 
all is ok. Then when I turn South on and try to make  migrate, I get:

./manage.py migrate
> Running migrations for auth:
>  - Migrating forwards to 0001_initial.
>  > auth:0001_initial
> FATAL ERROR - The following SQL query failed: CREATE TABLE 
> `auth_permission` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` 
> varchar(50) NOT NULL, `content_type_id` integer NOT NULL, `codename` 
> varchar(100) NOT NULL);
> The error was: (1050, "Table 'auth_permission' already exists")
>  ! Error found during real run of migration! Aborting.
>  ! Since you have a database that does not support running
>  ! schema-altering statements in transactions, we have had 
>  ! to leave it in an interim state between migrations.
> ! You *might* be able to recover with:   - no dry run output for 
> delete_unique_column() due to dynamic DDL, sorry
>= DROP TABLE `auth_permission` CASCADE; []
>= DROP TABLE `auth_group` CASCADE; []
>= DROP TABLE `auth_group_permissions` CASCADE; []
>= DROP TABLE `auth_user` CASCADE; []
>= DROP TABLE `auth_user_groups` CASCADE; []
>= DROP TABLE `auth_user_user_permissions` CASCADE; []
>  ! The South developers regret this has happened, and would
>  ! like to gently persuade you to consider a slightly
>  ! easier-to-deal-with DBMS (one that supports DDL transactions)
>  ! NOTE: The error which caused the migration to fail is further up.
> Error in migration: auth:0001_initial
> DatabaseError: (1050, "Table 'auth_permission' already exists")
>
> Any ideas what do I do wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WR_xxyrJGusJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django community, is it active?

2012-12-19 Thread galgal
You should also look 
here: https://plus.google.com/communities/108940692418100611427

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XhlsXnUgj_QJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Redirects middelware not working as it should

2012-09-21 Thread galgal
I set my redirect, for example from: /testpage/mysite.php  to 
/my-new-django-site/
It won't work if i enter a page mydomain://testpage/mysite.php but works 
on: mydomain://testpage/mysite.php/
"/" trailing slash.

How to make it work?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vqWNxtzez5cJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



sorl-thumbnail or easy-thumbnail

2012-09-15 Thread galgal
What image engine to choose sorl-thumbnail or easy-thumbnail? I saw on 
github, that easy-thumbanil is still updates, and sorl last update is about 
5 months ago.
I use sorl for a while but want to try something else. Does easy-thumbnail 
work in admin when image are displayed? sorl has a special admin class - i 
haven't found it about easy-thumbnail

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-6KzpYRGIkwJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Internationalized URL different per language

2012-07-13 Thread galgal
I need to make an urlpattern different for each language, but following to 
the same view.

for example:
url(r'^category/(?P[\w-]+)/, 'news.views.category', name='category'), 
in english
url(r'^kategoria/(?P[\w-]+)/, 'news.views.category', 
name='category'), in polish

if you have EN set, "kategoria" won't work. Is it possible?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AY6AQuWxzEcJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to make a query?

2012-06-27 Thread galgal
I made it that way:

prev_months = Article.objects.dates('add_date', 
> 'month').filter(add_date__lt=datetime.date(int(year), int(month), 1))[:5]
> next_months = Article.objects.dates('add_date', 
> 'month').filter(add_date__gte=datetime.date(int(year), int(month) + 1, 
> 1))[:5]


On Wednesday, June 27, 2012 9:28:27 PM UTC+2, galgal wrote:
>
> I have a model Article. It has a datetime field, title and description.
> How can I get last 5 months from now, where there is at least 1 article 
> added? Other words - how to get last 5 months which are not empty?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Qa_SJtAS6KwJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to make a query?

2012-06-27 Thread galgal
I have a model Article. It has a datetime field, title and description.
How can I get last 5 months from now, where there is at least 1 article 
added? Other words - how to get last 5 months which are not empty?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BbMtFrpjLH4J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Migrating to Django 1.4

2012-06-19 Thread galgal
Have changed your old manage.py to new one?
Django 1.4 generates new manage.py. Maybe that's the problem?

On Tuesday, June 19, 2012 9:15:01 AM UTC+2, Vignesh wrote:
>
> Hi,
>
> I started migrating our django 1.2.3 project to django 1.4,
>
> Now the manage.py is not showing any management commands added by outside 
> apps like, haystack, south etc. Am I missing something obvious?
>
> -Thanks
> Vignesh
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1OTfZAXhJaMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Forum app for Django?

2012-06-17 Thread galgal
What forum app dou you reccomend. I need a standard functionality like 
moderators, nested categories, registration etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LDyYmwkEDpUJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin - how to change choices in inlines?

2012-04-17 Thread galgal
How can I change choices of a field in Inlines class? I can't use 
formfield_for_choice_field in Inlines, so what to use?
I must generate it in admin, because I need request to be passed.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/OkOuplaV_3UJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin - how to get all registeres models in templatetag?

2012-03-22 Thread galgal
I'm writing a custom admin stuff and need to get all registered models in 
Admin. Is this possible?
I need it to make some custom views on admin index page.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZGg0w69RYhMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Database image from models

2012-02-14 Thread galgal
Is there any free app to generate database image schema from all models 
from all apps? I need image with tables and relations shown.

Thanks for help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GPpQcpHmhH4J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Customize "This field is required" message.

2012-01-16 Thread galgal
You can specify error message using that: 
https://docs.djangoproject.com/en/1.3/ref/forms/fields/#error-messages

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/H4zyq5AY728J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin - user related modules in admin

2012-01-16 Thread galgal
I use extended user profile (class name: UserProfile). I made an app for 
this, named account. In settings I have set:AUTH_PROFILE_MODULE = 
'account.UserProfile'

But I made another model in that app named RestrictedUsername. I want to 
put there usernames, that will be reserved and not available in register 
process. I don't know why, but it doesn't appear in admin panel. I 
registered it:
>
> from django.contrib import admin
> from apps.account.models import RestrictedUsername
> class RestrictedUsernameAdmin(admin.ModelAdmin):
> list_display = ('username',)
> search_fields = ('username',)
> admin.site.register(RestrictedUsername, RestrictedUsernameAdmin)


Any ideas how to make it work?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/eUhARmLIvV4J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



change min_length in form __init__?

2012-01-11 Thread galgal
Is there any way, to change the field's *min_length* argument inside form 
constructor? That doesn't work:

def __init__(self, *args, **kwargs):
> super(CreateTeamForm, self).__init__(*args, **kwargs)
> self.fields['primary_color'].min_length = 4

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/laN38iWqC-oJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



cache problem but query is OK

2011-12-05 Thread galgal
I try to make a very simple cache usage:
myquery = 
UserProfile.objects.select_related('user').filter(status__exact=1).values_list('user__username',
 
'q_points').order_by('-q_points')[:50]
cache.set('test_cache', myquery, 3600)
print cache.get('test_cache')
I get an error:
UserProfile has no field named 'username'
The thing is query is OK and returns valid results.

Debug Toolbar shows that cache value:
([(u'admin', 2L), (user1', 0L), (testuser', 0L)], 3600)

I have no idea what is wrong :/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4-Bdfxea-_UJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to place a form in all subsites and process i on 1 url?

2011-10-13 Thread galgal
I need to place a form in all my subsites and home page. It's placed on 
right column. It's action is "/". If there are some errors I must display 
them.
I made Form class etc. I display it via {{ form.as_p }} and designed all.

The problem is - how to put it on all sites? I don't want to make form 
instance in all my views functions.

What is the best solution for that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/D-oc9OMkpykJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF with AJAX problem

2011-09-29 Thread galgal
Yes I have. It returns null if no cookie.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Y4TMZ5p-XYgJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF with AJAX problem

2011-09-29 Thread galgal
Yes, but that JavaScript code is useless until {% csrf_token %} or get_token 
is used. I don't use POST forms - only AJAX forms so I don't have that 
cookie made after page load.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/JYFq1-eA4WgJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



CSRF with AJAX problem

2011-09-29 Thread galgal
I have a problem/bug found? in AJAX with CSRF. I don't use {% csrf_token %} 
at all. I use only AJAX forms so - there is no cookie set for csrf. In taht 
case - https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#ajax is 
useless :(
I can use get_token to generate it, but I have to put it in all my sites so 
it has no sense. 

How can I make that cookie without using csrf tag?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SDNW2jMK0ngJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
I have my model done, the only thing is - how to validate if 1 or more 
checkboxes are checked. It should be done in admin - choices are displayed 
via Inline.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZbU-_CGCZsEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
But I need to do checks in Admin, not my view. I can't find a method to 
validate in Admin.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rRHhnv1GGfEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin - formset validation with counting checked elements

2011-09-22 Thread galgal
I make a mini poll system. To each question choices are related via FK. In 
admin I use Inline choices. Each choice has "correct" field (Boolean). When 
saving a poll I need to check if there is minimum 1 choice with "correct" 
selected. Which function in admin I must use, to do that validation?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/E_pX2IfyCBcJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin - delete with removing FK objects

2011-09-14 Thread galgal
I made what I wanted using signals:)
All works now. I use post delete to be sure that object is deleted, than I 
remove images.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EcDKuOgfY-oJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin - delete with removing FK objects

2011-09-13 Thread galgal
I have 2 models

class Article(models.Model):

active = models.BooleanField(default=False, db_index=True)

title = models.CharField(max_length=150)

class ArticleGallery(models.Model):

article = models.ForeignKey(Article)

image = 
models.ImageField(upload_to=settings.ARTICLE_GALLERY_IMG_UPLOAD_TO)



def delete(self, *args, **kwargs):

self.image.delete()

super(ArticleGallery, self).delete(*args, **kwargs)


But when i click delete in Article and submit it, elements are removed from 
database but ArticleGallery.delete() isn't fired up.
I need the delete method to be run when deleting Article. Any clues?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/TIPI-hi3_d0J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: When is it useful to run multiple admin sites?

2011-09-11 Thread galgal
Where can I find any info about hot to run it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/s5twxCSBgDMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Accessing tuple element in templatetag, / Generating multi-level lists.

2011-09-10 Thread galgal
Also look here: 
https://docs.djangoproject.com/en/1.3/ref/models/instances/#django.db.models.Model.get_FOO_display

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PTuHdkTpMtMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Accessing tuple element in templatetag, / Generating multi-level lists.

2011-09-10 Thread galgal
maybe try:
 {%for c in category.elements %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/oL6OVzsq2AEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



JavaScript translation problem

2011-09-04 Thread galgal


Hi I have a problem with JS translation in Django. I did everything like is 
said in documentation, so: I made .po then .mo files (django.mo, 
djangojs.mo). Translated files are in path: *myapp/locale/pl/LC_MESSAGES/* 
and *myapp/locale/en/LC_MESSAGES/* *Translations in .html and .py files work 
OK.* The only problem is that JS translation always displays original 
phrase, not translated. main urls.py:

urlpatterns += patterns('', (r'^jsi18n/$', 
'django.views.i18n.javascript_catalog',{}), )

template file in header (as first JS part):



All my js files are in path /myapp/site_media/js/ and the only .mo files are 
in path which I wrote before. I use gettext() in JS strings.

What did I do wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/mAC48MURo50J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to invalidate per-view cache?

2011-08-19 Thread galgal
I want to use per-view 
cache. 
I know how it's working, but where's the problem? How can I invalidate that 
cache? I must do it each time database records are changed. There is no info 
about how to do that:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Xh1TgeV5M7AJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to save inlines?

2011-08-08 Thread galgal
I need to override save method of inlines in admin. While saving photos, I 
need to add user id to DB column. I cant make it in model because there is 
no request data there. How can I do it in admin, to somehow get nad set user 
id?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/i-GrX2DQfaEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin - delete_selected problem

2011-08-02 Thread galgal


In admin.py file i paste:admin.site.disable_action('delete_selected')



And get an error:


KeyError at /

'delete_selected'

Django Version: 1.3 Exception Type: KeyError Exception Value:

'delete_selected'

Exception Location: 
c:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\sites.py
 
in disable_action, line 127

Any idea why it occurs? In my previous websites I haven't that error and it 
is strange for me.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/tduJes9etMUJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin - change ForeignKey display text

2011-07-27 Thread galgal


How can I change the display text in select while selecting a field which is 
as ForeignKey? I need to display not only the name of FK, but also name of 
it's parent.

Anybody can give a clue?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hTxrcKjq-f0J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Method call when deleting FK in admin

2011-07-22 Thread galgal


My models:class Spectacle(models.Model):

title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100 unique=False)
description = models.TextField()
class SpectacleGallery(models.Model):
spectacle = models.ForeignKey(Spectacle)
image = models.ImageField(upload_to=upload_path_handler, max_length=255, 
help_text=_(u'tylko pliki z rozszerzeniem .jpg'))
image_thumb = models.CharField(max_length=255, editable=False, blank=True, 
null=True)
def delete(self, *args, **kwargs):

image_thumb_abs = settings.MEDIA_ROOT + str(self.image_thumb)

# try to delete thumb and image

try:

remove(image_thumb_abs)

except Exception:

pass

try:

self.image.delete()

except Exception:

pass

super(SpectacleGallery, self).delete(*args, **kwargs) # Call the "real" 
delete() method.

#try to delete dir

try:

removedirs(settings.SPECTACLE_GALLERY_UPLOAD_PATH + str(self.spectacle_id))

except:

pass


Now in admin, when I delete from SpectacleGallery file is being deleted from 
disk and DB properly. The problem is when I want to delete Spectacle. 
Deletion page is asking if i'm sure to delete Spectacle and all related 
images. I confirm and: all records from database are deleted. Unfortunately 
files from SpectacleGallery are not deleted.I paste print into delete() 
method in SpectacleGallery. Nothing shows so my question is: Why delete 
method is not called when deleting it in that way? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6o66VmCVQqMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to disable specific field validaton in form?

2011-07-20 Thread galgal
I need to disable field validation in ModelForm. I want this validation not 
to validate some field. I have some situations (AJAX rendering form) when I 
want to return more complex form with additional fields. I pass POST to the 
form and render new one with post fields saved. Some new fields are added 
and they can't be validated. I pass flag to form and recognize when it 
happens. Should I make it in some clean functions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YYieKI6WHk8J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django - change select items display

2011-07-19 Thread galgal


I use ModelForm. One of fields is:

repertoire = models.ForeignKey(Repertoire)

I need to change it's display type. Instead of using *unicode* in display I 
want to show name and date of repertoire. How in ModelForm I can do that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/M4Lfow9YmGMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - utf8 filename

2011-07-19 Thread galgal
OK I managed to do that - I can upload utf8 files now.
But after uploading it i can't see file form field to change file:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dMN3ApTZEPAJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - utf8 filename

2011-07-19 Thread galgal
I use shared server so I think I have no access to apache settings. My 
language is set to 'pl' right now.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VhyngaodKbEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django admin - utf8 filename

2011-07-19 Thread galgal
How can I get rid of error when uploading files with utf8 name?
I can't find any solution:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/MbHzssKnwOgJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django - can't open image in model save()

2011-07-17 Thread galgal


def upload_path_handler(instance, filename):

return filename

class SpectacleGallery(models.Model):

image = models.ImageField(upload_to=upload_path_handler)

def save(self, *args, **kwargs):

Image.open(self.image)

super(SpectacleGallery, self).save(*args, **kwargs)

When I try to open it I get:

IOError at /admin/index/spectacle/1/
cannot identify image file

Why? File is a proper image. Does that file in save methos is not a good 
format for PIL?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/h3NJ7_3vezwJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django Cache - how to clear per-site cache?

2011-07-13 Thread galgal
I use per-site cache. In my admin actions I want to add some commnad to 
clear cache every time content is changed.
How can I clear per-site cache from admin?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/c_RwUpbOKmQJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Environment:


Request Method: GET
Request URL: http://localhost:8000/admin/auth/user/2/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'debug_toolbar',
 'templatelibrary',
 'apps.index',
 'apps.city']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Template error:
In template 
c:\python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\templates\admin\includes\fieldset.html,
 
error at line 6
   Caught KeyError while rendering: "Key 'password' not found in Form"
   1 : 


   2 : {% if fieldset.name %}{{ fieldset.name }}{% endif %}


   3 : {% if fieldset.description %}


   4 : {{ fieldset.description|safe 
}}


   5 : {% endif %}


   6 :  {% for line in fieldset %} 


   7 : 


   8 : {% if line.fields|length_is:'1' %}{{ line.errors }}{% 
endif %}


   9 : {% for field in line %}


   10 : 


   11 : {% if not line.fields|length_is:'1' and not 
field.is_readonly %}{{ field.errors }}{% endif %}


   12 : {% if field.is_checkbox %}


   13 : {{ field.field }}{{ field.label_tag }}


   14 : {% else %}


   15 : {{ field.label_tag }}


   16 : {% if field.is_readonly %}


Traceback:
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\core\handlers\base.py"
 
in get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\options.py"
 
in wrapper
  307. return self.admin_site.admin_view(view)(*args, 
**kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\utils\decorators.py" 
in _wrapped_view
  93. response = view_func(request, *args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\views\decorators\cache.py"
 
in _wrapped_view_func
  79. response = view_func(request, *args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\sites.py"
 
in inner
  197. return view(request, *args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\utils\decorators.py" 
in _wrapper
  28. return bound_func(*args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\utils\decorators.py" 
in _wrapped_view
  93. response = view_func(request, *args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\utils\decorators.py" 
in bound_func
  24. return func(self, *args2, **kwargs2)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\db\transaction.py" 
in inner
  217. res = func(*args, **kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\options.py"
 
in change_view
  1030. return self.render_change_form(request, context, 
change=True, obj=obj)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\contrib\admin\options.py"
 
in render_change_form
  708. ], context, context_instance=context_instance)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\shortcuts\__init__.py"
 
in render_to_response
  20. return HttpResponse(loader.render_to_string(*args, **kwargs), 
**httpresponse_kwargs)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\loader.py" 
in render_to_string
  188. return t.render(context_instance)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\base.py" 
in render
  123. return self._render(context)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\base.py" 
in _render
  117. return self.nodelist.render(context)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\base.py" 
in render
  744. bits.append(self.render_node(node, context))
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\debug.py" 
in render_node
  73. result = node.render(context)
File 
"C:\Python27\lib\site-packages\django-1.3-py2.7.egg\django\template\loader_tags.py"
 
in render
  127. return compiled_parent._render(context)
File 

Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Any idea how to overwrite it dynamically?
def get_form(self, request, obj=None, **kwargs):
self.exclude = ('user_permissions',)
return super(UserProfileAdmin, self).get_form(request, obj=None, 
**kwargs)
Throws:
TemplateSyntaxError at /admin/auth/user/2/

Caught KeyError while rendering: "Key 'password' not found in Form"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/771t3uo6qbgJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-06 Thread galgal
Ok but like I said in previous post, exclude = ('groups',) etc doesn't work 
:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-exygvWEN9UJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django admin - change permissions list

2011-07-05 Thread galgal
Is there any possibility to change permissions list in user edit page? I 
don't wan't to show all of permissions for example admin log entry or auth 
group etc.
How can I modify a main queryset to exclude some of it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AW8MzS1_2bEJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-05 Thread galgal
I made it in that way, and it works:
def get_fieldsets(self, request, obj=None):
if obj:
if request.user.id == 1:
return self.declared_fieldsets
else:
if obj.get_profile().type==1:
return (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 
'last_name', 'email')}),
(_('Important dates'), {'fields': ('last_login', 
'date_joined')}),
)
else:
return (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('first_name', 
'last_name', 'email')}),
(_('Permissions'), {'fields': ('is_active', 
'is_staff', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login', 
'date_joined')}),
)
else:
return self.add_fieldsets

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Mq--t4_P1qMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
Yes I read it.  exclude = ('groups',) throws:

Caught KeyError while rendering: "Key 'groups' not found in Form"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/V5P1M_GH80sJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
That's my code now - how to hide groups for example?

admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model = UserProfile
filter_horizontal = ('cities',)
extra = 1
max_num = 1
filter_horizontal = ('cities',)

class UserProfileAdmin(UserAdmin):
inlines = [UserProfileInline,]
list_filter = ('userprofile__type','userprofile__cities',)
search_fields = ['userprofile__type', 'username', 
'userprofile__cities__name', 'email', 'first_name', 'last_name',]

# show users list - if user_id=1 show all, else: show id's > 1
def queryset(self, request):
qs = super(UserProfileAdmin, self).queryset(request)
if request.user.id == 1:
return qs
return qs.filter(id__gt=1)

admin.site.register(User, UserProfileAdmin)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZzrytaO1EOcJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
I'm rather searchung the way to do that in my admin.py file not in core 
files.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sZ83LDHBIC8J.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django admin - hide remove link

2011-07-04 Thread galgal
How can I hide remove link in Django admin? I need to hide it in my code, 
not in permissions (only user with id=1 can see it no matter if any users 
are superusers)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2cpWateci3YJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django admin - how to hide some fields in User edit?

2011-07-04 Thread galgal
How can I hide fields in admin User edit? Mainly I want to hide permissions 
and groups selecting in some exceptions, but exclude variable doesn't work 
:/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ydsmKWUyXQMJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Odp: Re: Change language on login

2011-06-21 Thread galgal
Which solution did You use?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/cTfGWDuX48UJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



set language from user lang in DB?

2011-06-21 Thread galgal


What is the best way to set language that is in DB in UserProfile? I have 
option to select language for users and after selecting it, I update 
UserProfile table to set the language. While logging in, i need to get user 
language from his profile and set it. User changes are made by selecting 
options from list of languages.

How can I dod that in the best way?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/v2GQZXcaz0UJ.
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin list_filter only for superuser?

2011-05-26 Thread galgal
Is it possible to show list_filter only for superuser?
I want to show filter only for users that are superusers or have some 
permissions.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Get user/admin ID in admin form

2011-05-23 Thread galgal
Is there any possibility to get admin/user ID in my admin form? I need it to 
change queryset which displays some data. I use custom form by form = 
CityNewsAdminForm in admin class but have no idea how to get admin ID inside 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to use 2 different cache backends

2011-05-10 Thread galgal
I need to use memcached and file based cache.
I setup my cache in settings:

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'LOCATION': 'c:/foo/bar',
},
'inmem': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
dummy is temporary.
Docs says:
cache.set('my_key', 'hello, world!', 30)
cache.get('my_key')
OK, but how can I now set and get cache only for 'inmem' cache backend (in 
future memcached)? Documentation doesn't mention how to do that.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Djando admin - custom error when deleting

2011-04-06 Thread galgal
I would like to use validating fields connections, but ONLY when delete 
action is performed. What should I do to validate that fields given in form 
via admin, chech them and if something is wrong - display errors in admin. I 
use custom ModelForm as admin form, but have no idea how to check in it's 
validation if it's deleting or saving. Maybe I could use delete_model built 
in admin - but how to display errors within 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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin custom button in edit

2011-04-06 Thread galgal
Hi,
what is the best way to add custom button to save/save and edit buttons 
list?
I need to add it only in edit mode and only in one model.

Thanks for help.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to change form field in admin?

2011-04-05 Thread galgal
Is there any way to change type of 1 specific field? I want to change 1 
field from CharField to TextField. I know I can make a modelform and pass it 
to admin class, but is there any other way?
For example - can I somehow use formfield_for_dbfield?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django and sphinx - lib needed

2011-03-29 Thread galgal
What library can I use with Django to use Sphinx?
I found https://github.com/dcramer/django-sphinx but it's not supported 
yet:/

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: AW: MEDIA_URL not treated like static

2011-03-28 Thread galgal
Thanks, I didn't know that. 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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: AW: MEDIA_URL not treated like static

2011-03-28 Thread galgal
I forgot to tell I'm using Django 1.3. In that case - how to make it work 
with separate dirs? Or it can't be done on dev server?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



MEDIA_URL not treated like static

2011-03-28 Thread galgal
I have that dirs structure:
site_media/
|
---> static/
|
---> uploads/

static dir is set as STATIC_URL = '/site_media/static/'
uploads dir is set as MEDIA_URL = '/site_media/uploads/'

In that case on dev server (localhost:8000) media_url is not accessible via 
browser as static file, and whe I try to access it I get 404 error. How can 
i set it up to be seen as static?
In uploads dir are all files uploaded by users. static dir includes all my 
js/css/images

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: url - hot to set properly?

2011-03-27 Thread galgal
I have APPEND_SLASH True but / is not added :)

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



url - hot to set properly?

2011-03-27 Thread galgal
I need to make some settings in urls. I want admin site enabled and 1 view 
method to catch rest of the request parts.
So if someone's url is :/admin - ADMIN panel is show, also if someone pass: 
/admin/ (/ <- is important)
If someone pass: /, /contact, gallery,. my custom method is activated.
The problem i have is / on the end.

My urls:

from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
(r'^', include('apps.textcontent.urls')),
)


My app url:

from django.conf.urls.defaults import *
urlpatterns = patterns('apps.textcontent.views',
url(r'^(?P.*)$', 'index', name='index'),
) 


when i pass: /admin/ all is ok, but when I pass /admin - 
 apps.textcontent.urls are executed, but why?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin widget, pass additional variable?

2011-03-26 Thread galgal
I user that method to show image im my ImageField 
edition: 
http://www.psychicorigami.com/2009/06/20/django-simple-admin-imagefield-thumbnail/
I need to pass to my widget 1 additional variable - thumbnail address. How 
can I pass that variable to widget?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ImageField and quality after save

2011-03-25 Thread galgal
How can I set the image quality to 100? The default value in PIL i 75 and 
Django saves an image with that value.
Where can I change 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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Detect if file is being changed

2011-03-25 Thread galgal
But I don't use any forms. I have simple model with image and date. I use it 
only in my Admin.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Detect if file is being changed

2011-03-25 Thread galgal
I make some file operations in admin. I use ImageField for it. In model's 
save method I need to detect if new image is sent via form, or form file 
field is empty.
How can I detect it in my model's save method?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Very large files upload

2011-03-25 Thread galgal
I need to make system that allows to upload files that can be sized about 
500MB.
I want to use pluplod that sends chunks, then I want to merge it into 1 file 
on my server. Is i a good idea? Or to make reciving 1 big file via post.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



All views require login?

2011-03-17 Thread galgal
I need to make an application in which all views require login. Is there any 
good way to do that and not to use @login_required() decorator with all 
methods?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Order of WHERE statements in filter

2011-03-11 Thread galgal
I want to make a specific odrer of WHERE statements in my query to use 
multicolumn index in database.
But oder in code is not the same as result query:
code:
filter(user=self.user, province=self.province, city=self.city)

Mysql result:
WHERE (`accounts_usercity`.`province_id` = 6 AND 
`accounts_usercity`.`city_id` = 32 AND `accounts_usercity`.`user_id` = 26 )

How to force my own order?

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to delete ONLY m2m relation?

2011-03-09 Thread galgal
Thanks, but I don't want to delete any "main" objects. I want to delete ONLY 
1 specific relation - I know user and province, and want to unlink the user 
from province.

-- 
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, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to delete ONLY m2m relation?

2011-03-09 Thread galgal
model:
class Province(models.Model):
user = models.ManyToManyField(User, blank=True)
name = models.CharField(max_length=30, unique=True)

How can I delete relation when I know user_id and province_id? If i user 
delete() method it also removes province and I want to avoid 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, visit this group at 
http://groups.google.com/group/django-users?hl=en.