DRY in templates
Hi, I have several applications running and each of them has its own template files. They're working fine. Then, I decided that I should create another application that would merge all data information from each of those separated ones mentioned above. There were two problems to consider: 1- regarding data and views 2- regarding templates As for 1, I found a way that follows the DRY principle. For each function that would be requested I joined another field as an argument. From: ex: def viewListA(request): To:def viewListA(request, integrated = False): Integrated is True when the request is demanded by the global application. If Integrated == False, the function returns the html file corresponding to it; if True, it returns 'request'. So far, so good. Now, for part nr. 2. I didn't find a way not to repeat the same lines of the partial html files in a big global html one, for the application that merges all information. My concern is only about data information that is presented mostly in tables. I am aware of the {% extends ... %} tag, but it can only be used once per file. Otherwise, I could use that tag for each of the partial templates and would import the data blocks of each of them. My question is this one: Is there a way I don't have to repeat the same template coding for the above illustrated example? Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: variable multiple filter question
DavidA escreveu: > You build up a dynamic "and" query with a term for each checked box in > the UI. Then you use that compound query to filter your model objects. > > Now that I think about it, since this is an "and" you could also do: > > def my_view(request): > query = {} > for i in range(1, 13): > chk = "var%d" % i > if request.has_key(chk) and request[key]: > query[chk] = True > > objects = MyModel.objects.filter(**query) > I would like to thank you all for your help. I'm using an expression similar to the above example and it works flawlessly! Regards, Luis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
variable multiple filter question
Hi, I want to let a user of one application to be able to filter results in a complex way. There are twelve variables, all boolean, that can be used to perform these filters. In PostgreSQL, all data for these variables are thus saved as either True of False. There is no difficulty to apply individual filters. My problem regards the combination of a variable number of filters. The user is presented with twelve radio boxes. If he/she chooses to filter by var3 and var4, code should be built as, for ex., Animals.objects.filter(var3=True).filter(var4=True) or as Animals.objects.filter(var3=True, var4=True) In these cases, I want to filter all records where var3 and var4 are True, and all other variables are either True or False. But if he chooses to apply five filters, there will have to be five filter methods appended, or five key=values pairs as arguments. I tried to build an expression with all filter methods sequentially where only the value of the pair key=value would change, like: Animals.objects.filter(var1=a).filter(var2=b).filter(var3=c).filter(var4=d) and so on. But if so, is there any value for a, b, c, etc that would result in a non-filtering situation, like '*' in SQL? On the other hand, I could hard code every combination of filters possible, but there's for sure a simple way to achieve what I want. I tried to play with getattr but my difficulty was that var3, and all the others are included inside parenthesis not as strings, but as names of model's attributes. Since filter accepts a keyword argument, I also tried to use a dictionary as {"var3":True,"var4":False} but with no success. Please, I would very much appreciate your help on this. How can achieve what I want. Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
problem chained filter
Hi, I want a user to select a multiple filter through check boxes. The problem is that filtering in django doesn't return all the expected results. I tried both chained filtering and filters with anded conditions and the result is no different. I'm I missing something? Where's the flaw? - view def consultarFiltradasFiscalizacao(request): user = request.user r = Fiscalizacao() r.exercicio_2002 = request.GET.get('exercicio_2002', None) r.exercicio_2003 = request.GET.get('exercicio_2003', None) r.exercicio_2004 = request.GET.get('exercicio_2004', None) r.exercicio_2005 = request.GET.get('exercicio_2005', None) filtros = ['exercicio_2002','exercicio_2003','exercicio_2004','exercicio_2005'] for f in filtros: setattr(r,f, \ getattr(r,f) == 'on' and 'true' or 'false') print r.exercicio_2002 print r.exercicio_2003 print r.exercicio_2004 print r.exercicio_2005 #fichas = Fiscalizacao.objects.filter(exercicio_2002=r.exercicio_2002)\ #.filter(exercicio_2003=r.exercicio_2003)\ #.filter(exercicio_2004=r.exercicio_2004)\ #.filter(exercicio_2005=r.exercicio_2005) fichas = Fiscalizacao.objects.filter(exercicio_2002=r.exercicio_2002).\ filter(exercicio_2005=r.exercicio_2005).\ filter(exercicio_2004=r.exercicio_2004).\ filter(exercicio_2003=r.exercicio_2003) fichas = fichas.order_by('id') return render_to_response('fichas/fiscalizacao/todas.html', \ {"fichas": fichas,"user":user}) - output of the django server- 7543 false true true false [06/Sep/2006 17:44:36] "GET /fichas/fiscalizacao/consultar_filtradas/?exercicio_2003=on&exercicio_2004=on HTTP/1.1" 200 5472 5 fichas returned <--- this is INCORRECT --- postgreSQL In postgresql, when I try to select the same query, I get eight results, which is correct. # select id from fichas_fiscalizacao where exercicio_2004 = true and exercicio_2003 = true and exercicio_2002 = false; id 6 5 4 7 9 11 10 8 (8 rows) -- template -- The template has no filtering: {% block content-main %} {% if fichas %} {% for ficha in fichas %} {{ ficha.id }} {{ ficha.inspeccionar_nif }} {{ ficha.inspeccionar_nif_fk.nome|truncatewords:"2" }} {{ ficha.data|date:"Y-m-d" }} {% if ficha.utilizador.first_name %} {{ ficha.utilizador.first_name }} {{ ficha.utilizador.last_name }} {% else %} {{ ficha.utilizador }} {% endif %} Rever {% endfor %} {% else %} Não há fichas arquivadas. {% endif %} Thanks for any help, Luis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem accessing users and groups in Admin
Jay Parlar escreveu: > On 8/30/06, Luis P. Mendes <[EMAIL PROTECTED]> wrote: > >> I have something to add: >> - I can add or delete 'fichas' from the admin site with no problem. >> - This 0.95 version is an upgrade from 0.91. >> > > That last part is interesting. Did you have a database running against > 0.91, and then you upgraded just your Django to 0.95? I never used > Django pre-magic-removal, but there's a possibility that the required > database fields are different. > > Alternatively, something from 0.91 was maybe not upgraded properly > (either in your Django source code, or in your own code). You've read > the migration document? > > http://code.djangoproject.com/wiki/RemovingTheMagic > http://code.djangoproject.com/wiki/MagicRemovalCheatSheet > I followed the instructions of RemovingTheMagic but only grasped MagicRemovalCheatSheet. So, I'll try to find the error(s) on this file. Thank you for your help once again. Luis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem accessing users and groups in Admin
Jay Parlar escreveu: > On 8/29/06, Luis P. Mendes <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I posted this on Saturday, but since I had no replies, I'm reposting it. >> >> What should I look for to solve this problem: >> >> When I access http://127.0.0.1:8000/admin/ I get >> Groups >> Users >> in the Autho Fieldset. >> >> >> If I click on Users http://127.0.0.1:8000/admin/auth/user/ I get a list >> of all the users. >> >> When I click on any of them: http://127.0.0.1:8000/admin/auth/user/1/ >> like the superuser in this case: >> >> Page not found (404) >> Request Method: >> GET >> Request URL: >> http://127.0.0.1:8000/admin/auth/user/1/ >> >> Or starting again from admin: http://127.0.0.1:8000/admin/ >> I click in the +Add shortcut for Users: >> http://127.0.0.1:8000/admin/auth/user/add/ >> . >> DoesNotExist at /admin/auth/user/add/ >> Request Method: >> GET >> Request URL: >> http://127.0.0.1:8000/admin/auth/user/add/ >> Exception Type: >> DoesNotExist >> Exception Value: >> Exception Location: >> /usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py >> in __get__, line 163 >> >> Traceback (most recent call last): >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py" >> in get_response >>74. response = callback(request, *callback_args, **callback_kwargs) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/decorators.py" >> in _checklogin >>55. return view_func(request, *args, **kwargs) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/decorators/cache.py" >> in _wrapped_view_func >>39. response = view_func(request, *args, **kwargs) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/main.py" >> in add_stage >>243. manipulator = model.AddManipulator() >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/manipulators.py" >> in __init__ >>69. self.fields.extend(f.get_manipulator_fields(self.opts, self, >> self.change)) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" >> in get_manipulator_fields >>226. field_objs, params = >> self.prepare_field_objs_and_params(manipulator, name_prefix) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" >> in prepare_field_objs_and_params >>215. field_objs = self.get_manipulator_field_objs() >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" >> in get_manipulator_field_objs >>627. choices = self.get_choices_default() >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" >> in get_choices_default >>631. return Field.get_choices(self, include_blank=False) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" >> in get_choices >>292. return first_choice + [(x._get_pk_val(), str(x)) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py" >> in __str__ >>48. return "%s | %s" % (self.content_type, self.name) >> File >> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" >> in __get__ >>163. raise self.field.rel.to.DoesNotExist >> >>DoesNotExist at /admin/auth/user/add/ >> >> Request information >> GET >> No GET data >> POST >> No POST data >> . >> >> What should I try to look for to solve this problem? >> > > > Which database are you using? I'm using Postgres > Could you post your INSTALLED_APPS settings? INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'sedait.cadastro', 'sedait.ircac', 'sedait.subsidios
Problem accessing users and groups in Admin
Hi, I posted this on Saturday, but since I had no replies, I'm reposting it. What should I look for to solve this problem: When I access http://127.0.0.1:8000/admin/ I get Groups Users in the Autho Fieldset. If I click on Users http://127.0.0.1:8000/admin/auth/user/ I get a list of all the users. When I click on any of them: http://127.0.0.1:8000/admin/auth/user/1/ like the superuser in this case: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/1/ Or starting again from admin: http://127.0.0.1:8000/admin/ I click in the +Add shortcut for Users: http://127.0.0.1:8000/admin/auth/user/add/ . DoesNotExist at /admin/auth/user/add/ Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/add/ Exception Type: DoesNotExist Exception Value: Exception Location: /usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py in __get__, line 163 Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/decorators/cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/main.py" in add_stage 243. manipulator = model.AddManipulator() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/manipulators.py" in __init__ 69. self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_manipulator_fields 226. field_objs, params = self.prepare_field_objs_and_params(manipulator, name_prefix) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in prepare_field_objs_and_params 215. field_objs = self.get_manipulator_field_objs() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_manipulator_field_objs 627. choices = self.get_choices_default() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_choices_default 631. return Field.get_choices(self, include_blank=False) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_choices 292. return first_choice + [(x._get_pk_val(), str(x)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py" in __str__ 48. return "%s | %s" % (self.content_type, self.name) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in __get__ 163. raise self.field.rel.to.DoesNotExist DoesNotExist at /admin/auth/user/add/ Request information GET No GET data POST No POST data . What should I try to look for to solve this problem? Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Problem accessing users and groups in Admin
Hi, I would like to know what to look for to solve this problem. When I access http://127.0.0.1:8000/admin/ I get Groups Users in the Autho Fieldset. If I click on Users http://127.0.0.1:8000/admin/auth/user/ I get a list of all the users. When I click on any of them: http://127.0.0.1:8000/admin/auth/user/1/ like the superuser in this case: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/1/ Or starting again from admin: http://127.0.0.1:8000/admin/ I click in the +Add shortcut for Users: http://127.0.0.1:8000/admin/auth/user/add/ . DoesNotExist at /admin/auth/user/add/ Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/add/ Exception Type: DoesNotExist Exception Value: Exception Location: /usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py in __get__, line 163 Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/decorators/cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/main.py" in add_stage 243. manipulator = model.AddManipulator() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/manipulators.py" in __init__ 69. self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_manipulator_fields 226. field_objs, params = self.prepare_field_objs_and_params(manipulator, name_prefix) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in prepare_field_objs_and_params 215. field_objs = self.get_manipulator_field_objs() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_manipulator_field_objs 627. choices = self.get_choices_default() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_choices_default 631. return Field.get_choices(self, include_blank=False) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_choices 292. return first_choice + [(x._get_pk_val(), str(x)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py" in __str__ 48. return "%s | %s" % (self.content_type, self.name) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in __get__ 163. raise self.field.rel.to.DoesNotExist DoesNotExist at /admin/auth/user/add/ Request information GET No GET data POST No POST data . What should I try to look for to solve this problem? Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
admin, users, groups and permissions
Hi, After setting up the admin interface, I get access to the users and groups list. >From the FAQ, I've read that """ If you'd like to use the admin site to create users, upgrade to the Django development version, where this problem was fixed on Aug. 4, 2006. """ Not only, I'd like to create users from the admin interface, I'd also want to be able to include users in groups (or take users out of groups) and set permissions to users and groups through the admin interface. What steps should I take to do this? - do I gave to subclass the User and Group models in order to add these methods? Does this have issues when upgrading my 0.95 version in future? - or create a one to one relationship as I've read someone suggesting? http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model Is this being developed so that can be available by default? My admin interface has another issue that I think it was not supposed to happen. I can see a list of the users but when I try do access each of them, the web page required is not found. Do I have to insert some url definitions in the admin urls file? Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: how to assign permissions to users and groups?
thank you for your help! Luis P. Mendes Chris Long escreveu: > To add permissions. > For user: user.user_permissions.add(perm) > (I think, don't have the chance to double check) For group: > group.permissions.add(perm) > > For your question, the permission table contains the codename, verbose > name and content type of the object. In most cases, you could probably > get away without having the contenttype, but it might be a good idea to > put in there if you the permission is only to be used with that > specific model. So both are right, just depends on how you want to use > the permission. Also, probably a good idea to have the codename of the > form: app_name.code_name, it's the format used for the default > permissions and might make your life easier to keep it in the same > format. > > Chris > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: how to assign permissions to users and groups?
Chris Long escreveu: > If I have a group instance called students and I wanted to add it to > the user instance bill I would use: > bill.groups.add(students) > > If you want to have a permission for a view, you will have to use the > has_perm method that is within the user model (user.has_perm) and check > for the permission you want at the beginning of the view. E.g.: > > def view_students(request): >if not request.user.has_perm("university.view_students"): > raise PermissionDenied > But, how can I assign permissions to groups and users? And regarding my example: from the manage.py shell: >>> >>> from django.contrib.auth.models import Permission >>> >>> p = Permission(codename='subsidios.pode_consultar') >>> >>> p.codename 'subsidios.pode_consultar' >>> >>> p.save() from the Intac class of the subsidios package: class Intac: (...) class Meta: permissions = (("pode_consultar", "Pode consultar"),) This is what I get from the auth_permission table in postgreSQL: # select * from auth_permission; 74 | Pode consultar | pode_consultar| 32 75 | | subsidios.pode_consultar | which way is correct in the auth_permission table? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
how to assign permissions to users and groups?
Hi, What I want to do is to let users access some views but not others. Users can fit in groups. I've not set up the admin interface for this package because I don't find it useful for my purpose, at least yet. Users can already register themselves for the site. But they will only be able to access this package, and others, after I give them permission to it (either directly or by group membership). I've added the decorator user_passes_test that prevents any user to access the view that has no access. At the present time, no user has access besides the superuser. I've read the authentication.txt from beggining to the end, but couldn't find the way to assign permissions to individual users or to groups. I really miss a tutorial about this subject. After trying to set permissions through user and group instances' methods, all failed, I came across the Permission object, and found out something else that I don't understand either: from the manage.py shell: >>> from django.contrib.auth.models import Permission >>> p = Permission(codename='subsidios.pode_consultar') >>> p.codename 'subsidios.pode_consultar' >>> p.save() from the Intac class of the subsidios package: class Intac: (...) class Meta: permissions = (("pode_consultar", "Pode consultar"),) This is what I get from the auth_permission table in postgreSQL: # select * from auth_permission; 74 | Pode consultar | pode_consultar| 32 75 | | subsidios.pode_consultar | The line 74 (origined in the Intac class model) doesn't have the package name before the permission codename. Are both entries correct? What I really need is that someone could show me an example of: - assigning a user to a group; - assign a user permission to a view; - assign a group permission to a view. Sorry if this is a very trivial problem, but I really need an example to help understand how this works. Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: render to screen and dynamic file
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Ok, I *think* I understand your problem a bit better. > > One thing you can do is store some information (filename, or > something) in the session object for the user. Then it doesn't matter > how long it takes for the user to press the button (unless of course > they wait days, and expire the cookie). > Thank you for your answer. Would you mind sending me some link where such an example is implemented, if possible? It's easier to code with an example. Luis P. Mendes -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEoGZpHn4UHCY8rB8RAgDQAJsEv4gdh1PDadZyWseMb2wKKMze5QCfUPGY 0INvFwf9wNfTdcHoxacSxfU= =D05r -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: render to screen and dynamic file
Jay Parlar escreveu: > These might be of some assistance to you: > > http://www.djangoproject.com/documentation/outputting_pdfs/ > http://www.djangoproject.com/documentation/outputting_csv/ > > Jay P. I've read both previously to posting, but those don't seem to address my question of generating both a web page and a file at the same time of the latter after pressing a button in the former. Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
render to screen and dynamic file
Hi, The problem is I want to create a dynamic web page and to build a dynamic excel file based on the same data used for screen output. I haven't decided yet on: a) if the file is built only after a user presses a button in the rendered page and the request activates another view function; b) or the file is built automatically at the same time the web page is rendered. For b), I've thought of creating a function inside the rendering function of the view to generate the file, so that I'd have two returns of functions: one for the web page, another for the file. Can you give me some thoughts on how to do this, both for a) and b)? In an experimental attempt, I created all the code to build the file in a different function at the view file, and used the variable from the get_list query as global. It worked as in a), but sometimes the file generated had data from other request not the user's. The best approach seems to be to build the file generator as a class in the model file, which I've already done, but the problem described in a) and b) remains. If in a), data for the file has to be the same as rendered to the screen, even if the user takes some minutes to press the button. I'd appreciate some insights on this problem. Thank you in advance, Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: got unexpected keyword argument
thank you all for your help! Luis P. Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
got unexpected keyword argument
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm using version 0.91. To put it short, I get a TypeError when I try to use a foreign key. Here's what I have: _In Postgresql_ TABLE "cadastro_servicos" ( ~"id" serial NOT NULL PRIMARY KEY, ~"codigo" text NOT NULL, ~"nome" varchar(80) NOT NULL ); TABLE "cadastro_cadastros" ( ~"id" serial NOT NULL PRIMARY KEY, ~"serv_clientes_id" integer NOT NULL REFERENCES "cadastro_servicos" ("id"), ~"nome" varchar(200) NOT NULL, ~ (...) ); INSERT INTO "packages" ("label", "name") VALUES ('cadastro', 'cadastro'); INSERT INTO "content_types" ("name", "package", "python_module_name") VALUES ('servico', 'cadastro', 'servicos'); INSERT INTO "content_types" ("name", "package", "python_module_name") VALUES ('cadastro', 'cadastro', 'cadastros'); As _django models_: class Servico(meta.Model): ~codigo = meta.TextField(maxlength=4) ~nome = meta.CharField(maxlength=80) ~def __repr__(self): ~return self.nome class Cadastro(meta.Model): ~serv_clientes = meta.ForeignKey(Servico) ~nome = meta.CharField(maxlength=200) ~ (...) ~def __repr__(self): ~return self.nome when I try: lista_sps = cadastros.get_list(servicos__id__exact=2) from within a view, I get: TypeError at /cadastro/pesquisa/ got unexpected keyword argument 'servicos__id__exact' The same happens from the interactive shell. |>> cadastros.get_list(servico__nome__icontains='bel') |>> cadastros.get_object(servico__nome__icontains='bel') |>> cadastros.get_object(codigo__icontains='bel') I've also tried, just in case: |>> cadastros.get_object(Servico__nome__icontains='bel') |>> cadastros.get_object(Servicos__nome__icontains='bel') If I try to get a list or a object from either of the two classes alone (with no references to the other) I have no problems getting the information I want. How did I build this? First I've developed the Cadastro model, and did 'python manage.py install cadastro'. At this time, cadastro had no serv_clientes field. Later on, I added the Servico class to the model, added the table to Postgresql and changed the Cadastro model to include the serv_clientes field. Everything seems alright for me, but not for django. Why does 'got unexpected keyword argument' happen? Can you give me some hints? Luis -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEUmG4Hn4UHCY8rB8RAhCyAJoCzUTmRlf52kDubk4t5qVYhynJjQCeMoqi sx0jE2ZESvUYozVrYxAMg0c= =npYm -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: advice location of site for production and devel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thank you for your help. I was able to load the index page of the only application I developed of my project using apache, but I needed to change some urls. I haven't yet understand this process completely. So I ask you for some 'light'. I have the project in /home/luis/myproject. Is it for a security reason that it should not be placed under htdocs? or other... 1- I run the django server and when I do http://localhost/application everything runs ok; 2- First thing I need to know is this: If it is a project with some applications, the project should have a home page. From this home page, the user can choose from running applications. In the tutorial I've read nothing about that project home page. How can I do it? Create a view under /home/luis/myproject? It didn't seem to work. 3- Or it could be an index.html file placed under htdocs, served by apache with links to 'application'. For me this solution would suit my needs at the moment, since the home page doesn't need any dynamic contents. If so, how to configure both django and apache settings? and how can I refer back to the index.html from inside any application? 4- What I have in httpd.conf is as suggested in the documentation. The problem is the only way I could manage Apache to find the index page of my application was to change the urls of myproject. To access the application with apache, I need to type http:/localhost/myproject/application. From the django server, which runs from inside the project directory, if I want to load an application ~ index, I just have to type http://localhost/application! If you could show me some examples it would be very nice. Luis -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEOaLgHn4UHCY8rB8RAmFbAJ9/py27Wr8oHhwqdrPi5aQ4fwZCJgCbBzgs UKVHH9h3jFpfAuxzIcVi40c= =TzD0 -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
advice location of site for production and devel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm building my first dynamic web site using Django. mod_python is installed and runs well. I tried the example supplied at its docs. I thought of having a development site under my /home account and it is running fine with the django pre-built runserver command. But, I'd like to copy the project, from time to time to under apache's htdocs/ for production. I'm having some problems with it: """ EnvironmentError: Could not import DJANGO_SETTINGS_MODULE 'djangoSite.settings.main' (is it on sys.path?): """ Even when I edit httpd.conf to point to the devel directories it doesn't work as should: I get a list of the files of that directory and not the view I created. So, my questions are: 1- Do you usually use different production and development directories? 2- If so, is it possible to post the httpd.conf configuration of the django and perhaps mod_python definitions? 3- Do I need to change any values in the 'myproject' settings, or to run any initialization command to put it to work under apache? Luis -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEMmPzHn4UHCY8rB8RAldgAJ9miU9DFZ+/VNHAy/h7RpK0SzemfgCfcppQ 1SX6zecmWVR1PFcYPI8/Idg= =HVAu -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---