Re: Using the Django Admin to change a password.
I was getting this error also, the tickets suggested I had a custom User proxy model or something, when in fact I didn't. What I _had_ done was commented out the admin.autodiscover() in my urls and manually registered the django.contrib.auth.models.User model manually. Using admin.autodiscover() seems to have fixed my problem. Cheers, Aaron -- 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: newbie: Filter an inclusion tag
Hello, Filter it in your inclusion template, for instance if your tag returns a result from your auction object: def il8n_attr(context, arg, arg2, lang_code): # do you processing return {'result': my_result} register.inclusion_tag('il8n-inclusion.html', takes_context=True)(il8n_attr) # template: {{ result|truncatewords:50 }} ...for instance... Hth, Aaron pihentagy wrote: > Hi all! > > I have an inclusion tag: > {% i18n_attr auction 'description' LANGUAGE_CODE %} > > I don't know how can I filter it with truncatewords. > > {% i18n_attr auction 'description' LANGUAGE_CODE|truncatewords:10 %} > doesn't work. > > Any ideas? > > thanks > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Newbie FileField/ImageField Problems
Hi Brian, Something like this should work for you: if form.is_valid(): photo = Photo() photo.save_source_file(form.cleaned_data['source'].filename, form.cleaned_data['source'].content) # redirect/etc Hth, Aaron brianmac wrote: > For the life of me I can't get django to upload a file. > I have all of the settings correct, PIL installed and correct enctype. > > My model is as follows: > > class Photo(models.Model): > source = models.ImageField(upload_to='images') > > Then in my view I try: > > Photo(request.FILES).save # I receive and Index error. > > Photo(request.POST, request.FILES).save # I receive and Index error. > > Photo(source = request.FILES).save # I receive and Index error. > > Photo(source = request.FILES['image']).save # puts dictionary(ie: > {'content':,'file-type':...) in db and does not upload file > > Also the model works when I use the admin interface. > > Any Ideas? > > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: {{ media_url }}
Hi Bobby, If you are referring to the media url that should be available via the context processor, then the variable in your template should be: {{ MEDIA_URL }} Unless you specifically are defining 'media_url' in your view. Hth, Aaron Bobby Roberts wrote: > i've got two templates in the same directory. My css works fine on > one template but not the other. My link to the css is > > > > Can you think of any reason it would work fine for one template and > not the other when the templates are in the same dir? > > > > BR > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: why so slow?
If it makes any difference to you at this point: I run django-nfa on a intel 825 dual core with 2GB of ram, eclipse, and a multitude of other apps running, and django dev server reloads my applications about as fast as I can change from the ide to the browser. My other developer, on the other hand, is running a core2duo with 2GB ram on vista, same setup, and he generally gets 5 second page loads for the admin side of things, and around the same for the dev server to reload. Could possibly just depend on the machine? Aaron [EMAIL PROTECTED] wrote: > im running part 2 of the tutorial right now and im inside the admin. > when connecting to localhost it is s slow, 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Building filter strings dynamically
Similarly, this will work also: field = 'sections' qry = qry.filter(**{field+'__name__exact': 'shooting'}) Cheers, Aaron John Lenton wrote: On Fri, May 9, 2008 at 6:19 PM, Greg Fuller <[EMAIL PROTECTED]> wrote: Hello, I'm trying to build filter strings dynamically. The normal way works: qry = qry.filter(sections__name__exact='printing') This does not work: filter_str = "sections__name__exact='shooting'" qry = qry.filter(filter_str) . The error is "too many values to unpack" at django/db/models/sql/ query.py in add_filter, line 933 I realize something outside normal name-spacing is probably happening, since "sections__name__exact" doesn't have to be defined anywhere. But is there any way to build the parameter to the filter dynamically? the usual python way of building dynamic args: filter = {'sections__name__exact': 'shooting'} qry = qry.filter(**filter) --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: mod_python error
You could have also used: urlpatterns = patterns('', (r'^$', 'qsm.recs.views.matrix'), (r'^users/', include('qsm.recs.urls')), because (as you know now) the python path was looking up to your project directory, but not as far as your application directory... Aaron bcurtu wrote: I got it! It was my apache config, I have included the path to the root of the project: PythonPath "['/home/bcurtu/ws-python','/home/bcurtu/ws-python/qsm'] + sys.path" Now it works, thanks! On 18 abr, 19:17, "Michael Wieher" <[EMAIL PROTECTED]> wrote: i guess the relative path is the question i assume ws-python is the directory your main urls file is in and the recs directly lives in it, with an __init__.py file ? On Fri, Apr 18, 2008 at 12:15 PM, bcurtu <[EMAIL PROTECTED]> wrote: Hi, I have set up my apache with mod_python. When I call my main page on /, it works fine. However, when I try to access to other applications (/users/23) I get this error: ImproperlyConfigured: Error while importing URLconf 'recs.urls': No module named recs.urls My main urls.py code is: urlpatterns = patterns('', (r'^$', 'qsm.recs.views.matrix'), (r'^users/', include('recs.urls')), ... and more And of course, I have a recs/urls.py file with a correct configuration... My mod_python config is : SetHandler python-program PythonHandler django.core.handlers.modpython PythonPath "['/home/bcurtu/ws-python'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE qsm.settings PythonDebug On Everything looks fine, isn't 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: wordpress hooks and actions system in django?
I thought I would chime in here as well, having a good deal of code written for WordPress, and now some experience with Django. I had originally contemplated the same idea, create a plugin system like that of WP until I started to understand the power of applications. In my mind it would be a terrible amount of work to create a system to read a plugin's structure, handle permissions (if needed) and then be compatible with the template system, when it's very simple to create an app to do something pluggable (say a classifieds application). The ease with which you can build new features in django, and make them available to other projects far outweighs any advantage I can think with some kind of plugin system (just my opinion). I try to write the applications for my project as if they needed to be pluggable, as few dependancies as possible, etc. And as far as wp filters go, the signal system should be more than capable. Do your need to provide the ability for another person to write 'plugins' or functionality for django? I'm thinking maybe there is something you know how to do well in wordpress but aren't sure how it's done/available in django? Cheers, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Displaying the id in admin
Hi Tom, In some places I *believe* object_id gave me results in my own templates. The next option is to try to access the context, but I believe you may have to write a template tag to use it (not totally sure). Here's an example I used: ### //test/templatetags/my_tags.py from django.template import Library, Node from django import template from django.contrib.auth.models import User from test.models import MyUserProfile register = Library() class CurrentUserProfile(Node): def render(self, context): try: pid = MyUserProfile.objects.get(user=context['object_id']).id # get the id for the profile of the currently edited user except: pid = 0 # no user? (bad code, just an example) return pid def user_profile_id(parser, token): return CurrentUserProfile() user_profile_id = register.tag(user_profile_id) ### //templates/admin/auth/user/change_form.html {% extends "admin/change_form.html" %} {% load my_tags %} {% block form_top %} {% if user_profile_id %} Edit this user's profile {% endif %} {% endblock %} Make sure your template dir is in your settings. There could be an easier way too, but this worked for me. Cheers, Aaron Tom Badran wrote: > Is there a way i can display the id of an object in the admin pages? > I've had a look over the docs and nothing jumps out. This is using > django svn > > Thanks > > Tom > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin inlines question
Hey guys, Thanks for the replies. Part of the issue I was having is I had the extras keyword in the wrong subclass (I had it in the options class for my model, instead of the inline class). It appears the functionality is working as it should be for now... Cheers, Aaron Brian Rosner wrote: I am using newforms admin and have a custom UserProfile model set in my inlines for my User, is there a way to limit the UserProfile to 1 for the User? Right now it's trying to offer 4 profiles for the user, and 'extras=1' doesn't seem to affect how many are displayed (I don't want extras anyway, I just want 1). This is a known issue with newforms-admin. See [1] for more details and a patch (I have not looked at the patch, but should soon). For the record, the keyword argument to inline_formset is not "extras". It should be "extra" without the "s". [1]: http://code.djangoproject.com/ticket/6075 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
newforms-admin inlines question
Hi List, I am using newforms admin and have a custom UserProfile model set in my inlines for my User, is there a way to limit the UserProfile to 1 for the User? Right now it's trying to offer 4 profiles for the user, and 'extras=1' doesn't seem to affect how many are displayed (I don't want extras anyway, I just want 1). Thanks in advance, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: using mod_python to host several django apps on the same vhost?
Hey Charles, I believe you will find that answer specifically here: http://www.djangobook.com/en/1.0/chapter20/ "If you need to put two Django installations within the same VirtualHost, you’ll need to take a special precaution to ensure mod_python’s code cache doesn’t mess things up. Use the PythonInterpreter directive to give different directives separate interpreters..." Cheers, Aaron [EMAIL PROTECTED] wrote: using mod_python to host several django apps on the same vhost? Hi, I'd like to host several django applications at http://foo.bar.com/x, http://foo.bar.com/y, etc. Currently I'm managing them all in the same vhost, using Apache locations to direct each URL to a different Django project. However, this technique requires me to rewrite my urls.py to accept ^x/admin instead of ^admin (which is bad and breaks portability). Is there a way that I can use mod_python to proxy http://foo.bar.com/x/admin/ to Django as /admin/ while still remembering which Django project it's running? Thanks, charles --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Strange issue with too many Foriegn Keys
Hey Michael, I ran across this article a couple days ago that seems to have a workaround to your problem: http://scottbarnham.com/blog/2007/08/22/edit-inline-with-imagefield-or-filefield-in-django-admin/ Hope that helps, Aaron Michael Newman wrote: > I am trying this new way of inheriting a lot of information for a > project I am working on. This site I need to extend the user profile, > then certain people can have their own sites and then those sites can > have 10 photographs to add to a slide show. > > so I have: > > exampleapp.py > -- models.py > > class Profile(models.Model): >models.ForeignKey(User, unique=True) >... > > class WebSite(models.Model): >models.ForeignKey(Profile) >... > > class WebsiteImage(models.Model): >models.ImageField(upload_to='myimagedir', core=True) >models.ForiegnKey(WebSite, edit_inline=models.TABULAR, > num_in_admin=10,max_num_in_admin=10) >... > > I create a Website and save a bunch of images. I click back on the > WebSite to edit it. I click save without editing anything. Go back to > look at the item and the Images are no longer there. Nor are the > database tables. > > This is really confusing. Does anyone have any ideas? Is this a known > issue or something dumb that I am doing? Thanks in advance for any > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting up Apache & mod_python on my development computer
Brandon, I just realized also, from your original error: EnvironmentError: Could not import settings 'testproject.settings' (Is it on sys.path? Does it have syntax errors?): No module named testproject.settings. Does it have syntax errors? Aaron Aaron Fay wrote: Hey Brandon, Here's my exact setup: SetHandler python-program PythonPath "['C:\django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproject.settings PythonDebug On SetHandler None SetHandler None "testproject" is here "C:\django\testproject", settings file is "C:\django\testproject\settings.py". I put both "C:\Python25\Scripts;c:\Python25\" in my system PATH. Running an XP SP2 box, wamp5 version 1.6.4, Apache 2.0.58(win32), mod_python 3.3.1, Python 2.5.1 Don't know if there's anything else I can tell you that might help, good luck with it... Aaron Brandon Taylor wrote: Hi Guys, Yes, I've tried that as well. No dice. Ugh! b On Feb 6, 1:22 pm, Michael Hipp <[EMAIL PROTECTED]> wrote: Is there a reason this line looks like this: > Instead of like this: > Michael Brandon Taylor wrote: Well, still no working solution, but here is my httpd.config now: SetHandler python-program PythonPath "['C:/django_projects/', 'C:/Python25/lib/site-packages/ django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproject.settings PythonDebug On I'm wondering if I should move to a FastCGI setup versus mod_python, as that's how my shared environment is going to be configured. Thoughts anyone? I don't understand what the problem might be here. I'll see if I have any more luck on my Mac when I get home. - Brandon --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Setting up Apache & mod_python on my development computer
Hey Brandon, Here's my exact setup: SetHandler python-program PythonPath "['C:\django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproject.settings PythonDebug On SetHandler None SetHandler None "testproject" is here "C:\django\testproject", settings file is "C:\django\testproject\settings.py". I put both "C:\Python25\Scripts;c:\Python25\" in my system PATH. Running an XP SP2 box, wamp5 version 1.6.4, Apache 2.0.58(win32), mod_python 3.3.1, Python 2.5.1 Don't know if there's anything else I can tell you that might help, good luck with it... Aaron Brandon Taylor wrote: Hi Guys, Yes, I've tried that as well. No dice. Ugh! b On Feb 6, 1:22 pm, Michael Hipp <[EMAIL PROTECTED]> wrote: Is there a reason this line looks like this: > Instead of like this: > Michael Brandon Taylor wrote: Well, still no working solution, but here is my httpd.config now: SetHandler python-program PythonPath "['C:/django_projects/', 'C:/Python25/lib/site-packages/ django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproject.settings PythonDebug On I'm wondering if I should move to a FastCGI setup versus mod_python, as that's how my shared environment is going to be configured. Thoughts anyone? I don't understand what the problem might be here. I'll see if I have any more luck on my Mac when I get home. - Brandon --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Setting up Apache & mod_python on my development computer
Hey Brandon, I have mine working on the same rig as you (looks like). Here's a shot in the dark: # << add forward slash SetHandler python-program PythonPath "['C:/django_projects/'] + sys.path" # << remove 'testproject' PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproject.settings PythonInterpreter testproject # << I don't have this line in my config, maybe try commenting it out PythonDebug On I'm guessing your error comes from django looking for the settings module in /django_projects/testproject/testproject/ Like I said, shot in the dark, but hth... Aaron Brandon Taylor wrote: > Hi everyone, > > I have Apache 2 and mod_python installed on Windows. The mod_python > module is loaded and active. > > Here's a breakdown of where things are... > > Python is installed at: C:\Python25 > Django is installed at: C:\Python25\Lib\site-packages > \django > My 'testproject' in installed at: C:\django_projects\testproject > > I have the following entry for 'testproject' in my Apache httpd.conf: > > > SetHandler python-program > PythonPath "['C:/django_projects/testproject'] + sys.path" > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE testproject.settings > PythonInterpreter testproject > PythonDebug On > > > When I hit: http://localhost/testproject, I receive the following > error: > > EnvironmentError: Could not import settings 'testproject.settings' (Is > it on sys.path? Does it have syntax errors?): No module named > testproject.settings. > > When I use the command line and start the built-in server for the > project, it will run and I get the Django welcome page. I added an > environment variable called PYTHONPATH and pointed it to C: > \django_projects, but I still get the error. > > Can anyone point me in the right direction? I'd really like to be able > to test in an Apache/mod_python environment versus the built-in > server, as that is how my shared hosting provider is configured and > I'd like to avoid surprises. > > TIA, > Brandon > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Insert relational record
Hi List, First off, Django is wonderful :) Okay, I'm overriding a save method on a model, and need to jack into another model to add an entry into the db. Now if it was as simple as User, I could just create a new user, right? But the problem is I need to create an entry in a table that is a relational table for the User model (Table: auth_user_groups). Can I do that without custom sql? Thanks :) Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Override admin filters
Hi list, I'm wondering if there is a way to override the filters and and list_display on the built-in users view/model in the django admin. I would like to be able to filter/sort by group if possible. Thanks in advance, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Template tag arguments
Thanks for the replies fellas... I got around it for the time being by using context['object_id'] in my node class and it worked, but I'll rewrite it to use the resolver method... Thanks for the tip, Aaron Steven Armstrong wrote: Aaron Fay wrote on 02/04/08 21:21: Hi list, I have a custom template tag that is supposed to take an argument from the template kinda like this: {% profile_user_id object_id %}, problem is 'object_id' is literally showing up as 'object_id' and not 5 or whatever it's supposed to be. I think the issue is I'm working within the context or something (no idea really)... Read about resolve_variable at http://www.djangoproject.com/documentation/templates_python/#passing-template-variables-to-the-tag --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Template tag arguments
Hi list, I have a custom template tag that is supposed to take an argument from the template kinda like this: {% profile_user_id object_id %}, problem is 'object_id' is literally showing up as 'object_id' and not 5 or whatever it's supposed to be. I think the issue is I'm working within the context or something (no idea really)... Any thoughts? Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Accessing user variable in edit user form
Hi list, Stuck again :P I have a couple questions: I'm trying to create a link in the {% block form_top %} of an admin template to link to the profile of the current user I'm editing but {{ user.id }} always gives me the id of the user logged in (me). Does this form use a request object or something? If so, is there a way to 'inspect' the values of the object being edited? I have tried a couple things on the command line API but can't seem to recreate the same conditions to give me workable results. Can someone shed some light on the 'inline_related_objects' block in the admin ({% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %})? I've been digging and can't find much for resources, although this one post promises to do what I originally wanted to do, but I can't seem to get it to work either (http://copiousfreetime.blogspot.com/2007/05/inlinerelatedobjects.html) Thanks for your insight :) Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Extend single admin template
Fixed my own problem :P turns out it was user error (go figure...) /templates/admin/auth/user/change_form.html did the trick... Thanks anyway :) Aaron Aaron Fay wrote: Hi list, I have successfully extended a custom model's template following the instructions in the djangobook, but I tried to do the same with a built-in template (edit user form) by adding {% extends "admin/change_form.html" %} {% block form_top %} Edit this user's profile {% endblock %} to a file called change_form.html ... my custom profile template is /templates/admin/test/myuserprofile/change_form.html I *thought* since the url pattern was similar for the edit user page, I could just put the same form in another folder like one of these: /templates/admin/test/auth/change_form.html /templates/admin/test/auth/user/change_form.html /templates/admin/test/user/change_form.html /templates/admin/test/users/change_form.html << i was guessing at this one but none of those seem to work. I checked the documentation (still looking...). Am I missing something obvious? Thanks, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Extend single admin template
Hi list, I have successfully extended a custom model's template following the instructions in the djangobook, but I tried to do the same with a built-in template (edit user form) by adding {% extends "admin/change_form.html" %} {% block form_top %} Edit this user's profile {% endblock %} to a file called change_form.html ... my custom profile template is /templates/admin/test/myuserprofile/change_form.html I *thought* since the url pattern was similar for the edit user page, I could just put the same form in another folder like one of these: /templates/admin/test/auth/change_form.html /templates/admin/test/auth/user/change_form.html /templates/admin/test/user/change_form.html /templates/admin/test/users/change_form.html << i was guessing at this one but none of those seem to work. I checked the documentation (still looking...). Am I missing something obvious? Thanks, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Conditional admin template inheritance
Hi again, Found the answer in the documentation (right in front of my face...) Aaron Aaron Fay wrote: > Hi List :) > > I want to be able to include some javascript on a specific automated > admin page, is there a way to just include my custom template block if > I'm editing a specific model? I really like the automated admin forms, > but it may be that I just have to sit down and write custom templates... > > Thanks for your insight, > Aaron > > > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Complex relationship for user profile
Hi Peter, I did a little more digging, and I'm not sure if my answer is in option 1 or 2... I am just using the automatic admin interface for my model at this point, with Django configured to use AUTH_PROFILE_MODULE = 'myapp.myuserprofile'. Is it safe to assume either model is saved first, or is there a reference to this behavior somewhere? 2nd question: does option 1 assume that I am using a custom form/template? If 'no', is it then possible to have the UserProfile model display the Users.email within it's form? And what might that look like? I'm trying to wrap my head around this new framework...still puzzled :S Thanks again, Aaron Peter Rowell wrote: Failing a response to that one must mean I'm asking for something that is undoable. Uh, this isn't McDonald's. Slow/no response does not immediately equate to undoable. It more likely means that people who might have answered the question were doing something else (watching the debate, coding, sleeping, having a life). Regarding your question: Depending on the dynamics of your app, you might investigate the following: 1. If the profile is updated first and you want to propagate some changes to the associated User record, try overriding the save() method for UserProfile, do your thing, and then call super(UserProfile, self).save() to finish. 2. If the opposite is true (User is changed and you want to propagate to UserProfile), avoid the temptation to hack contrib/auth/models.py. Instead, use signals. See http://code.djangoproject.com/wiki/Signals. See http://www.martin-geber.com/weblog/2007/10/29/django-signals-vs-custom-save-method/ for a discussion on the difference between custom save and signals. 3. Modifying the admin can be useful, but can the data only be changed through the form? If yes, then proceed. If no, then option 1 or 2 is a better way to capture the change, regardless of the source of the change. HTH, Peter --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Conditional admin template inheritance
Hi List :) I want to be able to include some javascript on a specific automated admin page, is there a way to just include my custom template block if I'm editing a specific model? I really like the automated admin forms, but it may be that I just have to sit down and write custom templates... Thanks for your insight, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Complex relationship for user profile
I'll try those, Peter, thanks for the response... Aaron Peter Rowell wrote: Failing a response to that one must mean I'm asking for something that is undoable. Uh, this isn't McDonald's. Slow/no response does not immediately equate to undoable. It more likely means that people who might have answered the question were doing something else (watching the debate, coding, sleeping, having a life). Regarding your question: Depending on the dynamics of your app, you might investigate the following: 1. If the profile is updated first and you want to propagate some changes to the associated User record, try overriding the save() method for UserProfile, do your thing, and then call super(UserProfile, self).save() to finish. 2. If the opposite is true (User is changed and you want to propagate to UserProfile), avoid the temptation to hack contrib/auth/models.py. Instead, use signals. See http://code.djangoproject.com/wiki/Signals. See http://www.martin-geber.com/weblog/2007/10/29/django-signals-vs-custom-save-method/ for a discussion on the difference between custom save and signals. 3. Modifying the admin can be useful, but can the data only be changed through the form? If yes, then proceed. If no, then option 1 or 2 is a better way to capture the change, regardless of the source of the change. HTH, Peter --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Complex relationship for user profile
Okay, Failing a response to that one must mean I'm asking for something that is undoable... could anyone provide an easy way to accomplish this by maybe extending the admin template or something? I'm convinced retrieving the data would be very simple, but is there a way to get it to save as well? Can you extend the form handler for an admin page? Thanks again, Aaron Aaron Fay wrote: > Hi list! (first post) > > I've created a small application to suit a new project I am working on, > however I have a question regarding using the user profile feature. I > have the setup working properly according to the documentation and it > works, what I need to know is if I can create a field in my user profile > model that will mimic or update fields on the users table. For example, > when I add a model for the profile, I would like to create a > relationship so I can display and update the user's email on my admin > page for the profile model, and not have to go to the users edit page to > do so (and actually it would be handy for a couple fields...) > > Not sure how to pull this off, I'm only a couple days into Django (and > loving it!) > > Thanks for the help, > Aaron > > > > > > --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Complex relationship for user profile
Hi list! (first post) I've created a small application to suit a new project I am working on, however I have a question regarding using the user profile feature. I have the setup working properly according to the documentation and it works, what I need to know is if I can create a field in my user profile model that will mimic or update fields on the users table. For example, when I add a model for the profile, I would like to create a relationship so I can display and update the user's email on my admin page for the profile model, and not have to go to the users edit page to do so (and actually it would be handy for a couple fields...) Not sure how to pull this off, I'm only a couple days into Django (and loving it!) Thanks for the help, Aaron --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
problem with database
hi my db is sqlite3 when i use admin , i shows me the tables but i can't do anything with them : Database error Something's wrong with your database installation. Make sure the appropriate database tables have been created, and make sure the database is readable by the appropriate user. what's wrong here? --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Inconsistent SQL generated for ForeignKey fields
Forgot to mention, I use MySQL 5.1. On May 23, 4:29 pm, Fay <[EMAIL PROTECTED]> wrote: > Hi, > > I encountered a situation that foreign key constraints were generated > differently for the same data model. > > Below is my test model that has 2 identical sets of 1-to-many tables. > When I run django sqlall command, however the foreign key constraints > were built differently, one used column constraint while the other > used table constraint. It seems the table names contribute to this > behavior. Although they function very similarly, I wonder why that > happened. > > from django.db import models > > class a1(models.Model): > a1c1 = models.CharField(maxlength=200) > > class a2(models.Model): > a2c1 = models.ForeignKey(a1) > a2c2 = models.CharField(maxlength=200, core=True) > > class x1(models.Model): > x1c1 = models.CharField(maxlength=200) > > class x2(models.Model): > x2c1 = models.ForeignKey(x1) > x2c2 = models.CharField(maxlength=200, core=True) > > Results from sqlall command: > > BEGIN; > CREATE TABLE `test_a1` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `a1c1` varchar(200) NOT NULL > ); > CREATE TABLE `test_x2` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `x2c1_id` integer NOT NULL, > `x2c2` varchar(200) NOT NULL > ); > CREATE TABLE `test_x1` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `x1c1` varchar(200) NOT NULL > ); > ALTER TABLE `test_x2` ADD CONSTRAINT x2c1_id_refs_id_11de27b2 FOREIGN > KEY (`x2c1_id`) REFERENCES `test_x1` (`id`); > CREATE TABLE `test_a2` ( > `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, > `a2c1_id` integer NOT NULL REFERENCES `test_a1` (`id`), > `a2c2` varchar(200) NOT NULL > ); > CREATE INDEX `test_x2_x2c1_id` ON `test_x2` (`x2c1_id`); > CREATE INDEX `test_a2_a2c1_id` ON `test_a2` (`a2c1_id`); > COMMIT; > > Thanks. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Inconsistent SQL generated for ForeignKey fields
Hi, I encountered a situation that foreign key constraints were generated differently for the same data model. Below is my test model that has 2 identical sets of 1-to-many tables. When I run django sqlall command, however the foreign key constraints were built differently, one used column constraint while the other used table constraint. It seems the table names contribute to this behavior. Although they function very similarly, I wonder why that happened. from django.db import models class a1(models.Model): a1c1 = models.CharField(maxlength=200) class a2(models.Model): a2c1 = models.ForeignKey(a1) a2c2 = models.CharField(maxlength=200, core=True) class x1(models.Model): x1c1 = models.CharField(maxlength=200) class x2(models.Model): x2c1 = models.ForeignKey(x1) x2c2 = models.CharField(maxlength=200, core=True) Results from sqlall command: BEGIN; CREATE TABLE `test_a1` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `a1c1` varchar(200) NOT NULL ); CREATE TABLE `test_x2` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `x2c1_id` integer NOT NULL, `x2c2` varchar(200) NOT NULL ); CREATE TABLE `test_x1` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `x1c1` varchar(200) NOT NULL ); ALTER TABLE `test_x2` ADD CONSTRAINT x2c1_id_refs_id_11de27b2 FOREIGN KEY (`x2c1_id`) REFERENCES `test_x1` (`id`); CREATE TABLE `test_a2` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `a2c1_id` integer NOT NULL REFERENCES `test_a1` (`id`), `a2c2` varchar(200) NOT NULL ); CREATE INDEX `test_x2_x2c1_id` ON `test_x2` (`x2c1_id`); CREATE INDEX `test_a2_a2c1_id` ON `test_a2` (`a2c1_id`); COMMIT; Thanks. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
How to define unsigned integer primary keys with auto increment for MySQL
I'm using MySQL. The primary key field generated by django uses integer, not unsigned. I'd like to us unsigned integer instead. I can explicitly specify PositiveIntegerField with primary_key option, but that doesn't seem to give me auto increment. Any ideas? Thanks. --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---