Django Admin limits

2010-04-29 Thread Martin Tiršel
Hello, I am still a newbie exploring possibilities of Django but you learn advanced techniques often on really big applications. I have here my two projects I want to do in Django (1. advanced eshop system and 2. webhosting management [customer database, invoicing, webhosting settings, trouble ti

Insert model data into every page (base.html)

2010-05-05 Thread Martin Tiršel
Hello, I need to insert some data from database onto every page, so I inserted them into base.html. Until now, I was using generic views but it doesn't seems to be ideal for this case. Is there a way how to achieve this behaviour with generic views or I have to insert needed model into ever

News on every page

2010-07-08 Thread Martin Tiršel
Hello, I am programming a small CMS on Django, I have editable pages, now I want to add news. I have a website where I want to display these news on every page in right/left column. I have following questions: 1.) Where is the right place to place news loader? TEMPLATE_CONTEXT_PROCESSORS

Re: Is Django right for what I am trying to do

2010-07-08 Thread Martin Tiršel
On Thu, 08 Jul 2010 23:23:53 +0200, Bradley Hintze wrote: I guess I just don't like the model.py, views.py, templates, and url.py. In the tutorial you have to edit all of these and THEN you get something that you can send to the client. It's very confusing! How do they tie together? I probabl

Re: News on every page

2010-07-09 Thread Martin Tiršel
On Thu, 08 Jul 2010 18:07:58 +0200, Martin Tiršel wrote: Hello, I am programming a small CMS on Django, I have editable pages, now I want to add news. I have a website where I want to display these news on every page in right/left column. I have following questions: 1.) Where is the

Re: import model from other module

2010-07-18 Thread Martin Tiršel
On Sun, 18 Jul 2010 21:58:15 +0200, Andreas Pfrengle wrote: when I execute "manage.py syncdb" - however, the database table is not created. Why? What would I need to change to make it work (except copy- paste the code into my models.py)? Hello, do you have it in INSTALLED_APPS ? Regards

prepopulated_fields - slug and underscores

2010-07-18 Thread Martin Tiršel
Hello, if I use prepopulated_fields = {"page_slug": ("page_title",)} all spaces are replaced with hyphens. If I would like to use underscores instead, is there a way how to change it? Thanks, Martin -- You received this message because you are subscribed to the Google Groups "Django users

How to get gallery thumbnails without multiple database queries

2010-07-18 Thread Martin Tiršel
Hello, I have: class Gallery(models.Model): ... class Image(models.Model): gallery = models.ForeignKey(Gallery) ... Now, on some page, I am listing all galleries and I want for every gallery first three (or three flagged, ...) images as thumbnails. I can go through

Re: Is Django right for what I am trying to do

2010-07-18 Thread Martin Tiršel
On Fri, 09 Jul 2010 16:50:14 +0200, derek wrote: More complex or more detailed? (I would argue that The Django Book is about as high quality as you are ever going to get for a free tutorial) Try: http://www.hoboes.com/NetLife/pytown/django-beyond-sql/ or: http://opensourcebridge.org/20

Re: How to get gallery thumbnails without multiple database queries

2010-07-19 Thread Martin Tiršel
On Mon, 19 Jul 2010 00:50:04 +0200, Martin Tiršel wrote: Hello, I have: class Gallery(models.Model): ... class Image(models.Model): gallery = models.ForeignKey(Gallery) ... Now, on some page, I am listing all galleries and I want for every gallery first three

Re: Getting old projects to run on 1.2 with Ubuntu

2010-07-25 Thread Martin Tiršel
On Sun, 25 Jul 2010 07:17:48 +0200, Nikhil Somaru wrote: Hi I'm using Ubuntu Lucid 10.04. I had previously installed Django 1.1.1 via the repos. I downloaded the django 1.2 tarball. Ran "sudo setup.py install" after extracting, and it seems the installation went fine. However, when I ru

Re: setting up datebase

2010-07-25 Thread Martin Tiršel
On Sat, 24 Jul 2010 07:57:02 +0200, john wrote: Hi all, I am following the django book. I am to the point of setting up my datebase. It instructs me to enter the command: python manage.py sqlall. When I do I get no output, and no errors. It just returns me to the . python manage.py val

Overwriting a default form

2010-07-25 Thread Martin Tiršel
Hello, I am programming (and learning django+python) a CMS. The core is working, now I am adding features and utils. One of them is a contact form. I have default functionality, but I want the user to overwrite default contact form in case he wants some fields added/removed or add some othe

Help with localization

2010-07-25 Thread Martin Tiršel
Hello, I can not get my translation working. Structure: * minicms - CMS project * userproject - project using minicms - minicms |-plugins ||-contactform |||-locale |||-templatetags |||-forms.py * forms.py: # -*- coding: utf-8 -*- from django import forms from django.utils.translation import u

Re: Help with localization [SOLVED]

2010-07-26 Thread Martin Tiršel
On Mon, 26 Jul 2010 03:46:10 +0200, Lachlan Musicman wrote: On Mon, Jul 26, 2010 at 11:16, Martin Tiršel wrote: Gah, my eyes were closed. Have you also added the appropriate Middleware product? As you see here: http://docs.djangoproject.com/en/dev/topics/i18n/deployment/#topics-i18n

Form label suffix

2010-07-31 Thread Martin Tiršel
Hello, If i do following, it works: form = ContactForm(label_suffix=":") print form Your name:... but here it is missing ':': form['name'].label_tag() u'Your name' I need to customize form output, so I can not use print form or as_p(), etc. and I am using following: {% for field in f

ManyToManyField limiting choices

2010-08-09 Thread Martin Tiršel
Hello, I have a gallery model and an image model. First, I create some galleries, then I insert images into them. But now, I want to add multiple thumbnails feature for galleries (thumbnails representing the gallery, not thumbnails for images inside gallery), so I added ManyToManyField and

filtering related object in template

2010-08-09 Thread Martin Tiršel
Hello, I can do: {% for image in gallery.image_set.all %} ... {% endfor %} but my image model has: is_thumbnail = models.BooleanField() and I want to limit displaying only these images which have is_thumbnail=True. I can create a method on the image model, which returns images I want to, b

How to automatically insert user_id in admin

2010-08-17 Thread Martin Tiršel
Hello, I need to auto-fill currently logged in user in admin after saving a model, but can not find a solution :( In save method of a model is no access to the HttpRequest object, so I don't know how to get the User. I found a "solution" with Modelform (http://stackoverflow.com/questions/

Re: How to automatically insert user_id in admin

2010-08-18 Thread Martin Tiršel
I will answer myself. The solution is ModelAdmin.save_model(...) method: class TaskAdmin(admin.ModelAdmin): exclude = ('user', ) def save_model(self, request, obj, form, change): obj.user = request.user obj.save() Martin On Wed, 18 Aug 2010 02:01:33 +02

Where and how should I write translations

2010-09-02 Thread Martin Tiršel
Hello, I can not find in Django documentation a word about translating variables or strings with variables. I have: ... {% trans question_category %} ... django-admin.py makemessages creates .po but without a mention about this template line ({% trans "some text" %} is ok). It is clear, th

Re: Where and how should I write translations

2010-09-02 Thread Martin Tiršel
quot;later" :( Thanks, Martin On Thu, 02 Sep 2010 13:33:36 +0200, Martin Tiršel wrote: Hello, I can not find in Django documentation a word about translating variables or strings with variables. I have: ... {% trans question_category %} ... django-admin.py makemessages creates .po

Re: Where and how should I write translations

2010-09-04 Thread Martin Tiršel
don't know about? Thanks, Martin On Thu, 02 Sep 2010 17:03:01 +0200, Tom Evans wrote: On Thu, Sep 2, 2010 at 2:15 PM, Martin Tiršel wrote: I tried to create second .po file with manual translations, but had no luck either :( `compilemessages` creates the second .mo file, but doesn

Re: Where and how should I write translations [SOLVED]

2010-09-05 Thread Martin Tiršel
I solved it by creating a new python file with: # -*- coding: utf-8 -*- from django.utils.translation import ugettext as _ translation_strings = [ _(u'string'), _(u'another string'), ... ] So easy :) Martin On Thu, 02 Sep 2010 13:33:36 +0200, Martin Tirše

Tabular output

2010-09-30 Thread Martin Tiršel
Hello, I have a list of images from database I need to print in a table and this seems to be more difficult as I expected. Is there an easy way how to print results into table? Number of collumns depends on a constant in settings. Thanks, Martin -- You received this message because you a

Re: Tabular output

2010-09-30 Thread Martin Tiršel
: Hi, Could you elaborate on your issue ? If you have hard time positionning you can loop on you list items and use loop.counter or loop.counter0 and use the divisibleby tag to display line start and end Regards, Xavier. Le 30 sept. 2010 à 14:15, Martin Tiršel a écrit : Hello, I have

Re: Tabular output

2010-09-30 Thread Martin Tiršel
HTML5) validator and it didn't complain: cell1 cell2 cell1 Regards, Carlton On 30 Sep 2010, at 13:49, Martin Tiršel wrote: Thanks, this looks better, but one more thing - If I have for example 3 colu

Re: Tabular output

2010-09-30 Thread Martin Tiršel
ndfor %} Martin On Thu, 30 Sep 2010 15:29:58 +0200, aid wrote: On Sep 30, 2:14 pm, Martin Tiršel wrote: Sorry, my bad, I thought that it has to be completed, so it is ok. Problem would be only if I wanted to make cell borderds, around the empty cells too. For the cells you don'

Tracking changes of a model

2010-10-30 Thread Martin Tiršel
Hello, I am using Django admin to create/update some records. Now, I need to track changes. After somebody updates a record, I need to see what was changed and then create a text log like: changed `name`: oldvalue -> newvalue, changed `email`: o...@mail.xy -> n...@mail.xy Where is the righ

Re: Tracking changes of a model

2010-10-31 Thread Martin Tiršel
+0200, Daniel Roseman wrote: On Oct 30, 11:15 am, Martin Tiršel wrote: Sounds like django-reversion would fit the bill: http://github.com/etianen/django-reversion -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Call a function after a model with inlines is created

2010-10-31 Thread Martin Tiršel
Hello, I have two models BillingRequest and BillingRequestItem. I am using admin and inlines, so when I am creating BillingRequest, I have some fields for BillingRequestItems. Now, I need to send an email with some information from both models when I create new BillingRequest record. But I

Re: Call a function after a model with inlines is created [solved]

2010-11-08 Thread Martin Tiršel
On Sun, 31 Oct 2010 20:15:19 +0100, Daniel Roseman wrote: On Oct 31, 4:46 pm, Martin Tiršel wrote: If this is only needed for the admin, you probably want to override the ModelAdmin's response_add method. This is called after the add form has been processed and all the resulting ob

login() and 'unicode' object is not callable error

2010-03-19 Thread Martin Tiršel
Hello, can somebody help me with this error? I am a Django beginner but I don't see any errors in the code: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/administration/ Django Version: 1.1.1 Python Version: 2.6.4 Installed Applications: ['django.contrib.auth', 'djang

Re: login() and 'unicode' object is not callable error [SOLVED]

2010-03-19 Thread Martin Tiršel
On Fri, 19 Mar 2010 16:23:40 +0100, Paulo Almeida wrote: I think what's happening is you are assigning a string to the 'login' variable: login = request.POST['login'] So when you get to: login(request, user) login is the text and not the function. HTH, Paulo Yes and I forgot to mention

Two user account types and login_required decorator

2010-03-19 Thread Martin Tiršel
Hello, I am programming an application where one part is customer database with accounts and settings for internal access, the second part is customer access with different interface and functionality. For internal access I am using django.contrib.auth and login_required decorator. This dec

How to save a file from filesystem

2012-02-06 Thread Martin Tiršel
Hello, I have a model with FileField with upload_to callable to save it into secific directory structure. I have a list of paths on filesystem with some files I need to create a record for. How can I open a file on the filesystem, assign it to my model and save so the file will be copied to

Re: How to save a file from filesystem

2012-02-06 Thread Martin Tiršel
I found it: myfile = File(open('/some/filesystem/path/file.jpg', 'r')) myfile.name = os.path.basename(myfile.name) myobj = MyObj.objects.get(id=123) myobj.myfile = myfile myobj.save() This saves the file under upload_to path correctly. On Mon, 06 Feb 2012 11:46:19

Count values grouped by date

2012-02-20 Thread Martin Tiršel
Hi, I have: class BannerStats(models.Model): ACTION_TYPE_VIEW = 0 ACTION_TYPE_CLICK = 1 ACTION_TYPES = ( (ACTION_TYPE_VIEW, 'view'), (ACTION_TYPE_CLICK, 'click'), ) banner = models.ForeignKey( Banner ) date = models.DateTimeField( aut

Re: Count values grouped by date

2012-02-20 Thread Martin Tiršel
On Mon, 20 Feb 2012 18:33:40 +0100, Tom Evans wrote: On Mon, Feb 20, 2012 at 5:17 PM, Martin Tiršel wrote: (btw, are you sure that works for views? looks like it is counting clicks as well) Yes, that was counting all records. This type of query is tricky to do in django. In SQL, you

Is there a place for new Django specialized hosting?

2012-03-21 Thread Martin Tiršel
Hello, I am playing with an idea to create a hosting service specialized for Django. I would be glad if you can provide some feedback if you would use such service (or why not) and what monthly fee would you pay for this. This would be based on virtual servers without root access (only un

Ignoring empty forms in a formset

2012-04-22 Thread Martin Tiršel
Hello, I have a formset and some JavaScript to add more forms into this formset. In a view, I iterate through the formset saving (not a ModelForm just Form with save method) each form: for form in formset: form.save() But I want to ignore empty forms that were added by JavasScript and not

Re: Ignoring empty forms in a formset

2012-04-23 Thread Martin Tiršel
Nobody knows how to ignore empty forms in a formset? I have to write some custom method on a form that checks all fields and returns False if any of the fields is filled or is there any other solution? Martin On Sunday, April 22, 2012 6:44:53 PM UTC+2, Martin Tiršel wrote: > > Hello,

Re: Ignoring empty forms in a formset

2012-04-24 Thread Martin Tiršel
scribed in the documentation. > > On Mon, Apr 23, 2012 at 15:42, Martin Tiršel wrote: > >> Nobody knows how to ignore empty forms in a formset? I have to write some >> custom method on a form that checks all fields and returns False if any of >> the fields is filled or

Re: Ignoring empty forms in a formset

2012-04-25 Thread Martin Tiršel
95] Is empty: True [2012-04-25 13:42:09,914] DEBUG [31099 140249342375680] [project.internal.forms:54] Saving PayOrderForm So both forms have empty_permitted == True. Management form in time of submit looks so: Thanks, Martin On Wednesday, April 25, 2012 11:03:49 AM UTC+2, Tom Evans wrote:

Re: Ignoring empty forms in a formset

2012-04-25 Thread Martin Tiršel
gh to skip > over blank new forms. > > Cheers > > Tom > > On Wed, Apr 25, 2012 at 12:55 PM, Martin Tiršel > wrote: > > I am using class based views and my code is: > > > > class PayOrdersView(AdminFormSetView): > > form_class = Pay

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
Hi, as Daniel wrote, the {{ p.source.all }} is a queryset you can access the same way as in {% for p in publisher.object_list %}. So you create a nested for loop. Martin On Sun, 11 Sep 2011 10:38:39 +0200, Petey wrote: And also how do I display more objets from that list? ;) Sorry for d

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
{{ p.source.all }} - is a list of source objects {{ p.source.all.0 }} - is the first item in the list of source objects (the same as p.source.all[0] in python) {{ p.source.all.0.some_attribute }} - you access some_attribute of the object source which is the first item in the list od source

Re: Getting a class using a variable name.

2011-09-11 Thread Martin Tiršel
Hi, you can do the import here to prevent circular import: class B(models.Model): def get_a_class(self): from test_a import A return A Martin On Sun, 11 Sep 2011 16:49:22 +0200, pbzRPA wrote: Hi, I have been struggling with this for a while now and I can't seem to find

Re: How to create Time Series Tables In DJango

2011-09-16 Thread Martin Tiršel
Hi, I think, that your app has a bad design if you need to do such things. You can have a hundred millions of records and be just fine and you can have a thousands of records and have problems if you do a bad design. If you split data over multiple tables, you will do the lookups over multi

Re: When is the django orm going to get a "group by" function ?

2011-09-16 Thread Martin Tiršel
You mean that? https://docs.djangoproject.com/en/1.2/topics/db/aggregation/#values Martin On Fri, 16 Sep 2011 14:05:13 +0200, dave bl wrote: When is the django orm going to get a "group by" function ? (this is srs buz ... Y NO HAZ?). I see that there have been various changes(getting close

Re: New user login problem

2011-09-16 Thread Martin Tiršel
Hi, did you set is_staff to True? Martin On Fri, 16 Sep 2011 14:20:14 +0200, marios wrote: Thank you. I did what you are saying. And I have tried creating several new users, but the error message is the same. On 16 sep, 08:49, "Szabo, Patrick \(LNG-VIE\)" wrote: Are you sure you've use

Django template IndexError

2011-09-21 Thread Martin Tiršel
Hello, I have this situation: class SomeClass(object): ... def __getitem__(self, key): ... raise IndexError() and now: context['somevar'] = {'one': 1, } context['anothervar'] = SomeClass() in template: {{ somevar.one }} - prints 1 {{ somevar.two }} - prints nothing,

Re: Django template IndexError

2011-09-21 Thread Martin Tiršel
It seems, that Django handles methods and variables indexes differently. So I solved it this way: e = IndexError() e.silent_variable_failure = True raise e Martin On Wed, 21 Sep 2011 23:36:58 +0200, Martin Tiršel wrote: Hello, I have this situation: class SomeClass(object

Parellel request from the same user in very short time

2011-09-24 Thread Martin Tiršel
Hello, I am using Apache with mod_wsgi and following setting: WSGIDaemonProcess dev.xyz.com processes=1 threads=5 user=xyz group=xyz display-name=dev.xyz.com I am observing some situations where a user sends the same request multiple times (double click?) where the time between these reque

Re: Parellel request from the same user in very short time

2011-09-25 Thread Martin Tiršel
On Sun, 25 Sep 2011 02:09:46 +0200, Russell Keith-Magee wrote: On Sat, Sep 24, 2011 at 10:08 PM, Martin Tiršel wrote: Hello, I am using Apache with mod_wsgi and following setting: WSGIDaemonProcess dev.xyz.com processes=1 threads=5 user=xyz group=xyz display-name=dev.xyz.com I am

Passing parameters to form in formset

2011-10-07 Thread Martin Tiršel
Hello, * Short version: How can I build a formset that creates so many form instances that a result set has records and passes one record from the result set to each form constructor? * Long version: I am building a browser game in Django. I have a GameBase that can have multiple Defen

Re: Passing parameters to form in formset

2011-10-07 Thread Martin Tiršel
On Fri, 07 Oct 2011 21:51:01 +0200, Martin Tiršel wrote: Hello, * Short version: How can I build a formset that creates so many form instances that a result set has records and passes one record from the result set to each form constructor? * Long version: I am building a browser

Translation problem with percent sign

2011-11-04 Thread Martin Tiršel
Hello, I am using Django 1.2.5. * template: {% trans 'If you cancel queued construction, you will get 75% of resources back' %} * django-admin.py makemessages -l sk produces: #: templates/core/buildings/construction.html:65 #, python-format msgid "If you cancel queued construction, you w

Re: Translation problem with percent sign

2011-11-05 Thread Martin Tiršel
On Fri, 04 Nov 2011 15:54:04 +0100, Martin J. Laubach wrote: Just remove the line with "python-format" from your translation since it isn't a format string after all. mjl Thanks, this is working. But after makemessages It comes again so I have to fix this line every time.

models.Q raising exception

2011-12-01 Thread Martin Tiršel
Hello, why this is not working? from django.db import models ... GameProfile.objects.get( models.Q(nick=nick) | models.Q(user=self.user), world=self.world, ) but this is working? from django.db.models import Q ... GameProfil

Re: Django E-Commerce Framework

2011-12-07 Thread Martin Tiršel
On Tue, 06 Dec 2011 22:45:05 +0100, Stuart Laughlin wrote: I have firsthand experience implementing satchmo for a very large storefront, and I can heartily recommend it. People who recommend writing your own ecommerce platform have an overly romanticized perspective. In my opinion ecommerce i

Raise validation error for empty formset

2011-12-14 Thread Martin Tiršel
Hi, I have a formset where I need to raise ValidationError if all forms in this formset are empty and submitted but I can not find any useful informations. Any suggestions? Thanks, Martin -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Raise validation error for empty formset

2011-12-23 Thread Martin Tiršel
Hi On Thu, 15 Dec 2011 12:52:44 +0100, Tom Evans wrote: On Wed, Dec 14, 2011 at 9:22 PM, Martin Tiršel wrote: Hi, I have a formset where I need to raise ValidationError if all forms in this formset are empty and submitted but I can not find any useful informations. Any suggestions

Initial data for dynamic field

2011-12-23 Thread Martin Tiršel
Hello, I have: class SomeForm(forms.Form): ... def __init__(self, *args, **kwargs): ... super(SomeForm, self).__init__(*args, **kwargs) ... self.fields['starting_location'] = forms.TypedChoiceField( label=_('Starting location'), ch

Re: Initial data for dynamic field

2011-12-23 Thread Martin Tiršel
On Fri, 23 Dec 2011 09:42:37 +0100, Mengu wrote: you need to set "initial" attribute of TypedChoiceField. Thanks, I knew about the initial only on form instance and not on field :) On Dec 23, 10:34 am, Martin Tiršel wrote: Hello, I have: class SomeForm(forms.Form): ...

Checkboxes for a list of items like in Django admin interface

2012-01-04 Thread Martin Tiršel
Hello, I have a list of items (from a model) I want to display with checkboxes (for deleting multiple objects at once). The same behaviour like in django admin (change list). I can do such thing in templates: {% for item in item_list %} {{ item }} {% endfor %} and in a view loop through

Re: Checkboxes for a list of items like in Django admin interface

2012-01-04 Thread Martin Tiršel
] notifications = Notification.objects.filter( id__in=id_list, ) Martin On Wed, 04 Jan 2012 12:11:11 +0100, Thorsten Sanders wrote: I do it this way: and in the view: todel = request.POST.getlist('todelete') ItemWatchList.objects.filter(user=request.user,id__in=todel).delete() On 04.01.2012 11:33, Ma

Transaction commited byt still receiving "Transaction managed block ended with pending COMMIT/ROLLBACK"

2012-01-16 Thread Martin Tiršel
Hello, This is the view (minimal version without POST processing block): @transaction.commit_manually() def create_free(request): context = {}; context['categories'] = Category.objects.all() transaction.commit() return render_to_response( 'advert/create_free.html',

Re: Transaction commited byt still receiving "Transaction managed block ended with pending COMMIT/ROLLBACK"

2012-01-16 Thread Martin Tiršel
On Mon, 16 Jan 2012 16:41:43 +0100, Tom Evans wrote: On Mon, Jan 16, 2012 at 3:34 PM, Martin Tiršel wrote: No, you could just subtly re-order your statements: Why I am doing everything the hard way? :))) Thanks, Martin -- You received this message because you are subscribed to the

Re: model for uploading a file - not working??

2012-01-25 Thread Martin Tiršel
On Wed, 25 Jan 2012 16:54:55 +0100, Krondaj wrote: in my model i'm using: from django.db import models, datetime, MEDIA_ROOT class RrsForm(models.Model): # upload_doc = models.FileField(upload_to 'documents') I get this error when I run (before running syncdb): python manage.py sql

Re: Installing Django on Ubuntu

2011-05-28 Thread Martin Tiršel
Hello, only short reply: 1.) Don't use distro packages for python packages 2.) Instal some libraries you will need (libmysqlclient-dev, python-dev, build-essential, python-setuptools, ...) 3.) Install virtualenv (either using distro package or easy_install/pip if you want/need newer one), cr

NoReverseMatch for custom admin URLs

2011-07-30 Thread Martin Tiršel
Hi all, the code: class CompanyProfileAdmin(admin.ModelAdmin): list_display = ( '__unicode__', 'city', 'premium_type', 'followers', 'manage_premium_account' ) ... def get_urls(self): urls = super(CompanyProfileAdmin, self).get_urls(

Re: NoReverseMatch for custom admin URLs [SOLVED]

2011-07-30 Thread Martin Tiršel
Sorry, my bad :) I forgot that first argument for patterns() is a string with view name prefix. That was all. Martin On Sat, 30 Jul 2011 11:52:21 +0200, Martin Tiršel wrote: Hi all, the code: class CompanyProfileAdmin(admin.ModelAdmin): list_display = ( '__unic

Execute code after the model with m2m is completely saved

2011-01-16 Thread Martin Tiršel
Hello, I am using (only) django admin to insert data and have: class ImageSize(models.Model): ... class Image(models.Model): size = models.ManyToManyField(ImageSize) ... I need to save original image that have been uploaded (this is ok) and then make resized copies depending on s

m2m_changed signal called multiple times?

2011-01-17 Thread Martin Tiršel
Hello, I have: * settings.py: ... import logging logging.basicConfig( level = logging.DEBUG, format = '%(asctime)s %(levelname)s %(message)s', filename = LOG_FILE, filemode = 'w' ) * models.py: class ImageSize(models.Model): ... class Image(models.Model): size = mode

Re: m2m_changed signal called multiple times?

2011-01-17 Thread Martin Tiršel
post_clear action when I am creating a new Image record? Thanks, Martin On Mon, 17 Jan 2011 11:53:05 +0100, bruno desthuilliers wrote: On 17 jan, 11:09, Martin Tiršel wrote: (snip) m2m_changed.connect(ready_to_resize, sender=Image.size.through, dispatch_uid="38fy3f73")

Re: Execute code after the model with m2m is completely saved

2011-01-17 Thread Martin Tiršel
I found two ways how to do it: *) m2m_changed signal - this is the best way *) save_model(self, request, obj, form, change) method for ModelAdmin - obj has current relations, form contains the new relations Martin On Sun, 16 Jan 2011 19:33:09 +0100, Martin Tiršel wrote: Hello, I am

Re: Django and google webmaster tools file

2011-01-19 Thread Martin Tiršel
This is a static file and should be served directly by webserver, so you need to configure your webserver to provide this file (like other static files but from another url). It is possible to server it by Django too, then you are looking for django.views.static.serve but It is not recommen

Re: Django and google webmaster tools file

2011-01-19 Thread Martin Tiršel
h the path you want it to be on and create the file as a template with only static content: urlpatterns += patterns('django.views.generic.simple', (r'^robots.txt$', 'direct_to_template', {'template':'robots.txt', 'mimetype':'text

Selecting related objects with condition

2011-01-31 Thread Martin Tiršel
Hello, I have a model: class Work(models.Model): ... user = models.ForeignKey( User ) closed = models.DateTimeField( blank=True ) ... Now, I want to print all users and for each user all Works closed between a specific date. If I don't need the "closed

Re: Selecting related objects with condition

2011-02-01 Thread Martin Tiršel
Thanks, I didn't know the {% ifchanged %} tag. Martin On Mon, 31 Jan 2011 22:58:55 +0100, Michael wrote: The easiest way would be to get a list of all closed work items, ordered by user: context['work'] = Work.objects.filter(whatever).order_by('user') {% for work_item in work %}

Re: Help on adding CSS to django project

2011-02-06 Thread Martin Tiršel
Hello, please read the documentation, everything you need to know, is described there. For development: http://docs.djangoproject.com/en/1.2/howto/static-files/ And for production: http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/ Regards, Martin On Mon, 07 Feb 2011 00:47:27

Bug in Django admin?

2011-03-07 Thread Martin Tiršel
Hello, I have such model: class BoolTest(models.Model): NO = False YES = True YES_NO_CHOICES = ( (NO, 'no'), (YES, 'yes') ) name = models.CharField( max_length=30 ) completed = models.BooleanField( default=NO, choices=YES_NO_CHO

Re: Bug in Django admin?

2011-03-08 Thread Martin Tiršel
Hello, On Mon, 07 Mar 2011 22:12:14 +0100, Michael Radziej wrote: Ahoj Martin, On Mon, 07 Mar 2011 12:49:32 +0100, Martin Tiršel wrote: When I use filter in Django admin (that produces URL .../admin/appname/booltest/?completed__exact=False), I get results which are with completed=True

Re: Bug in Django admin?

2011-03-09 Thread Martin Tiršel
Hi Michael, On Tue, 08 Mar 2011 11:05:40 +0100, Michael Radziej wrote: Hi Martin! Args--you're right. Stupid fingers :-) I meant .../admin/appname/booltest/?completed__exact=0 Does it work that way for you with 0 instead of False? Yes, if I rewrite URL to ?completed__exact=0, then I

unit tests and setUp method

2011-03-15 Thread Martin Tiršel
Hello, I am new to unit tests and I am using django.test.TestCase. What I don't understand, is this situation class GameWorldTests(TestCase): def setUp(self): self.test_world = GameWorld.objects.create( name='Testing world', game=GameWorld.GAME_TYPE_XY,

Re: unit tests and setUp method

2011-03-21 Thread Martin Tiršel
6:40 PM, Martin Tiršel wrote: I am new to unit tests and I am using django.test.TestCase. What I don't understand, is this situation class GameWorldTests(TestCase): def setUp(self): self.test_world = GameWorld.objects.create( name='Testing world',