Re: Admin inline for inherited model cant find pointer to parent model
Looking more into this, my parent model has a primary key field named 'code'. The inline forms do show the 'code' field for the child model instances, and the data is in the formset's querydict: QueryDict <... u'childmodel_set-0-code': [u'...'] ...> However the table column name for the one-to-one relationship between parent and child is called 'parendmodel__ptr__id', and the admin is looking for 'childmodel_set-0-parentmodel_ptr' in the formset data. Why? On Mon, Feb 13, 2012 at 10:43 AM, Demetrio Girardi wrote: > I have a child model that I wish edit inline in the admin site. When > trying to save edits I get a MultiValueDictKeyError: > > "Key 'childmodel_set-0-parentmodel_ptr' not found in " > > It seems to me the admin is trying to get the reference to the parent > model from the form data. How can I fix this? Do I need a custom form? -- 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 inline for inherited model cant find pointer to parent model
I have a child model that I wish edit inline in the admin site. When trying to save edits I get a MultiValueDictKeyError: "Key 'childmodel_set-0-parentmodel_ptr' not found in " It seems to me the admin is trying to get the reference to the parent model from the form data. How can I fix this? Do I need a custom form? -- 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: Generating a list of available templates
On 10 Feb 2012 at 14:50, Patrick Wellever wrote: > I want to make it a choice field that justs lists all the files in, for > example, > 'templates/flatpages/page_templates/', so the user can see what templates are > available and just > choose one from a select list. you can read the filesystem in the form's (or form field's) __init__. -- 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.
WSGIHandler freezes, how do I find out why?
I have a single django project, deployed on two separate installations of Apache + python + mod_wsgi. The first installation has python 2.6 and everything works fine. The second installation has python 2.7. With this one, a few things work correctly - namely django's debug 404 pages, the login page. However, when I try to access some views, WSGIHandler simply freezes forever and I have no idea how to debug this. Once the thing freezes, it stays frozen until I restart apache (not even 404 pages work anymore). I tried wrapping WSGIHandler in some dummy code in the wsgi script and that gets executed no problem. The development server runs fine on the same python 2.7 installation. -- 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.
ManyRelatedManager reference
I can't find a reference for ManyRelatedManager in the django docs. I have a few questions that you can ignore if there is in fact a reference somewhere and you can point me to it. If my model is class Model(models.Model): many = models.ManyToManyField(OtherModel) what does this do? Model.objects.filter(many = instance_of_other_model) why do these not work, and what is the correct way to do it? instance_of_model.many = another_instance.many instance_of_model.many.add(another_instance.many) If I have two instances of OtherModel, how do construct a queryset that matches all instances of Model that reference both? -- 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.
Determine gender from first name
This is not a django-specific question, but I couldn't find anything useful on the subject and have no better place to ask. Let's say I want to put "welcome {{user.first_name}}" on top of my template. In many languages, "welcome" has to be declined by gender. I have no use for the user's gender otherwise, so I don't want to ask for it in the registration process. How can I go about this? Is there a publicly available database of first names divided by language and gender? A public web-service that guesstimates the gender? -- 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.
Primary key for read-only models
I need to read data from an "external" database table from my django project. I am not interested in modifying the data, only reading it. Of course I would like to create a django model for the table, because it makes life so much more easier. I have already done this previously, however in this case the table has a multiple field primary key, unsupported by Django. There is no other field which is guaranteed to be unique that I can use as primary key in the Django model. Do I need to worry about this? or can I just slap the primary_key flag on any of the fields, since I will never be inserting or updating in that 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
project root or its parent in pythonpath?
Upon reading the django tutorial, I was under the impression that you should have the project root folder in your pythonpath, so that each app is available for import in modules, e.g. you can do import myapp However, my IDE seems to prefer putting its root in the pythonpath, so you'd have to import project.myapp and also it seems that the documentation for WSGI deployment expect the same (with project.settings) What is recommended? I have two apps which are inter-dependent and import stuff from one another; if I decide to go for the project.app route, is there a way to import things without a reference to the project name? otherwise the imports would have to be rewritten when the apps are installed in another projcet. -- 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: Advice/tips on how make private directory for each user?
Static files are not handled by django, so you would have to configure your webserver for authentication and access control. You can however create a django view that picks stuff from the filesystem and serves it as attachment: https://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-bro wser-to-treat-the-response-as-a-file-attachment -- 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.
Translating templates
My project has a bunch of text embedded deep within the html markup in templates that I need to translate. The text, imo, belongs to templates and it has no place in the application logic. >From what I understand, localization in templates is limited to variables, which is not useful to me. For example, I'll have a template like this: > > We are the greatest company in the world. yadda yadda. > > {% actual useful stuff%} > A lot of other useless text otherwise the page isn't professional > enough I cannot simply pass the template file to the translators because they would be confused by the markup. Is there a "correct" way to handle localization of decorative text? -- 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.