Re: How to move inline into or above fieldsets in django admin?
mind giving a short example? >From what I see in the template {% for fieldset in adminform %} {% include "admin/includes/fieldset.html" %} {% endfor %} {% for inline_admin_formset in inline_admin_formsets %} {% include inline_admin_formset.opts.template %} {% endfor %} I can either have it appear before or after the fieldsets. Not in between. On Dec 11, 11:26 pm, Wayne Smithwrote: > Well, the template is what controls the ordering of fields. You can create > your own template that Django will then use in the admin interface. From > there you can control exactly how things are displayed. > On Dec 11, 2010 1:30 PM, "mongoose" wrote: > > > Hi wayne, > > > to be honest I've no idea how i'd do that by overriding a template. > > > On Dec 11, 7:20 pm, wayne wrote: > >> On Dec 11, 8:05 am, mongoose wrote: > > >> > Hi there, > > >> > Currently I've got a recipe application like this: > > >> > class RecipeAdmin(admin.ModelAdmin): > >> > fieldsets = ( > >> > ('Recipe Details',{ > >> > 'fields': ( > >> > ('title', 'slug'),'description', > > 'difficulty', 'vegetarian', > > >> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > >> > ) > >> > }), > >> > ('Cooking Instructions', {'fields': ['instructions']}), > >> > ) > >> > inlines = [IngredientInline, PhotoInline] > > >> > The problem here is that the Ingredients are being listed after the > >> > Cooking Instruction which doesn't really fit. The best would be to > >> > have something like this: > > >> > class RecipeAdmin(admin.ModelAdmin): > >> > fieldsets = ( > >> > ('Recipe Details',{ > >> > 'fields': ( > >> > ('title', 'slug'),'description', > > 'difficulty', 'vegetarian', > > >> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > >> > ) > >> > }), > > >> > inlines = [IngredientInline, PhotoInline] > > >> > ('Cooking Instructions', {'fields': ['instructions']}), > >> > ) > > >> > Thanks a lot! > > >> I'm not sure if there is an admin setting that will allow you to > >> specify this ordering. Either way, you can always override the admin > >> template for this particular class. > > >> Read about it here: > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... > > >> Wayne > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group.> To post to this group, send email to > django-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on a hosting service
tiemonster wrote, on 12/11/2010 05:45 AM: > To use Django with Apache, it would be necessary to install *some* > python interpreter into the server. I used Django on our shared > hosting site using an .htaccess that called the mod_python handler in > Django. However, mod_python was already installed. If they are > offering to install mod_wsgi, then absolutely take them up on it. The > performance difference between mod_wsgi and pretty much every other > Apache arrangement cannot be understated. Thanks for clearing that up; I will definitely have them install mod_wsgi. But, will there be more for them to do than just installing the module? In other words, presuming that they are not already familiar with mod_wsgi, will I also have to ask them make some further modifications to the Apache config file, which I don't have access to, or can I do the rest myself with an .htaccess file? --Todd > On Dec 9, 8:56 pm, Todd Wilsonwrote: >> A couple of weeks ago I sent the message quoted below to the list. One >> reader (Daniel Roseman) replied and suggested that I might not need to >> ask the hosting service to install anything, quoting documentation from >> the FastCGI section, but it seemed to me (as explained in my reply on >> 11/28/2010) that mod_fastcgi had to be installed, which it isn't (or at >> least it's not in /etc/apache2/mods-available/). >> >> Anyway, I got through to the hosting provider's tech support with my >> request and got this reply: >> >>According to Django requirements (http://packages.debian.org/lenny >>/python-django) and our experience there is no need to have >>mod_python or mod_wsgi installed on the server. So, you could >>try to run Django web site on the server. If any problem arises we >>will install the mod_wsgi module. >> >> I wonder if they are referring to the development server here. Please >> correct me if I'm wrong, but I understood from the documentation that a >> vanilla installation of Apache would not be sufficient to deploy >> production Django applications, except possibly through (old-fashioned) >> CGI: some form of integration (mod_wsgi, mod_python, mod_fastcgi, ...) >> would be needed. Is that right? >> >> In any case, they are willing to install mod_wsgi. Not being very >> familiar with Apache configuration, can someone tell me how much of the >> WSGI configuration mentioned in the Django docs for WSGI deployment >> (http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/) can be >> done with an .htaccess file, and how much I will have to ask them to do >> for me? >> >> Thanks, >> >> --Todd >> >> Todd Wilson wrote, on 11/27/2010 07:20 PM:> I'm helping some friends improve >> a portal website they have created >>> using PHP, but which would be ideal for Django, in the sense that a lot >>> of the work they've already done, and would like to do as they improve >>> the site, would be easy to do in Django. They have a hosting contract >>> with Intermedia (http://www.intermedia.net/) and would very much like to >>> keep it. I've gotten ssh access to their server and went poking around >>> a bit, and, although python is available on the server (version 2.5.2), >>> there doesn't seem to be any support for WSGI, mod_python, FastCGI, or >>> the other deployment options listed in the documentation (at least I >>> didn't see them in /etc/apache2/mods-available/), and it doesn't look >>> like they support other frameworks (Rails, Drupal, Zope) either. >> >>> My question: I've always set up my own servers and don't have any >>> experience with web hosting; is there a minimal sort of request that I >>> could make to Intermedia that, if granted, would make it possible for me >>> (and presumably others) to deploy a Django site using their service, or >>> should I just try to convince my friends to find a different hosting >>> service? It seems like there would be many to choose from: >> >>>http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts >> >>> Thanks, >> >>> --Todd > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Generic Views - do you use them?
On Dec 10, 5:22 pm, Łukasz Rekuckiwrote: > > On Fri, Dec 10, 2010 at 9:37 AM, Rainy wrote: > > >> Is there a doc somewhere that details what the limitations are? How > >> do you tell if some task is definitely too much for new generic views? > >> I'm not using 1.3 yet and generally what I've been doing recently > >> doesn't seem to fit generic views but eventually I might use them. > > What kind of limitations you have in mind ? Well, not exactly sure. I looked at them a bit more and actually they look kind of nice. I think calling them generic views may be a bit misleading at this point because a lot of people probably will end up using them for all complex views while leaving functions for simpler ones. In other words, you might use predefined generics for the most basic views, then use functions for slightly more complicated ones and custom generic for everything else. -rainy -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
I ran the Django develplment server and everything runs fine. It's only when I go back to the other web server that things start to break on me. On Dec 11, 8:06 pm, Mike Dewhirstwrote: > On 12/12/2010 10:56am, jc wrote: > > > > > > > > > > > I've tried to fix my config files and it gives me a 500 error, here is > > what i see n the logs. I've been told by someone else that they think > > it's still my mod_wsgi/Apache configuration and not the error that I'm > > getting in the log about missing modules. Any suggestions? Here is the > > server error log message and my newly configured files: > > > # > > # error.log > > # > > mod_wsgi (pid=20698): Exception occurred processing WSGI script '/ > > srv/ > > www/duckling.org/store/wsgi-scripts/django.wsgi'. > > Traceback (most recent call last): > > File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ > > wsgi.py", line 230, in __call__ > > self.load_middleware() > > File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ > > base.py", line 42, in load_middleware > > raise exceptions.ImproperlyConfigured('Error importing middleware %s: > > "%s"' % (mw_module, e)) > > ImproperlyConfigured: Error importing middleware > > satchmo_store.shop.SSLMiddleware: "No module named > > satchmo_store.shop.SSLMiddleware > > I'm at a loss here as to how I find out if the problem lies with > > mod_wsgi or apache configs or django or satchmo. So, I'm posting here > > just in case someone might be able to help me out. Without some help > > this project is as good as doomed as I don't have a lot of skills and > > I'm learning along the way. > > The loading middleware error seems straightforward. My guess is the > module containing the middleware cannot be found. > > If you installed Satchmo correctly it will have added itself properly to > the Python path and that error wouldn't occur. > > If you are learning and still need to develop your skills I would > recommend using the Django dev server to try it out. > > hth > > Mike > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Is it possible to specify the html class attribute for a form field?
When you create your form, you can specify extra attributes to each widget of each field. For example: myfield = forms.CharField(widget=forms.Textarea(attrs={'cols':80, 'rows':80}) So as one of the keys in your attrs argument, you can make it 'class' and then provide the class name as the value. On Dec 11, 5:46 pm, codecowboywrote: > Thank you in advance for any feedback. > > Here is what I have {{ form.name }}. I would like to set the class > attribute for this form element to "style01". Is this possible? > > If it is not possible then I have been trying to get this working as > well without much luck. > maxlength="50" value="{{ form.name.value }}" /> > I realize that this syntax is incorrect but I'm trying to illustrate > what I am trying to do. Is there anyway to access the value of a form > field from the template? If the user submits data that does not > validate, I do not want them to have to fill out the form twice. > > I found one discussion suggesting that I make the form's cleaned data > available to the view but that feels hackish although I'm not above > it! I was just hoping that there was a cleaner way to do this. > > Thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
I think after that comment I'm slowly getting it but I still need to go back and learn more. Regardless of the the horrible security holes in my application, this still wouldn't do anything as far as *not* making this django app run, would it? In other words, I know it's insecure as hell to do what I'm doing but that is *not* the reason my django app is not running, correct? thanks again, j. On Dec 11, 7:09 pm, Mike Dewhirstwrote: > On 12/12/2010 10:35am, jc wrote: > > > You definitely lost me in some places but you've also cleared some > > things up in the process. I also noticed that I had " > www/wsgi-scripts>", which is lacking a directory for the > > WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my > > listing of my files in my project when I go to my address *but* I now > > get 500 Internal Server Error. I'm not sure if I should trust the logs > > Always trust the logs. If you know enough about Apache to mistrust the > logs then you wouldn't be here. > > > or maybe I've misconfigured something else (either in Apache or in my > > django.wsgi file)...I had this same issue yesterday 500 error... > > > Also, when you said "Somewhere in your Apache config you have denied > > access to the entire filesystem", do you mean *Apache* has done this > > so that it will keep others out of my project (not that I've actually > > done this somewhere, right?) > > Somewhere in your Apache config there will be something like this ... > > # forbid access to the entire filesystem by default > > Options None > AllowOverride None > Order deny,allow > Deny from all > > > ... which - as the comment says - locks the public out of everything on > the server. actually means the root of the server itself. > In other words /. The '/>' is not an XML closing tag even though it > might look like it. > > This is why you need to specifically open up public access to htdocs and > your wsgi script directory. Incidentally, it is also why your Django > code should not be in your your wsgi script directory. If it was Apache > could reveal it to the public - which is what I think you were > describing earlier. > > > > > After these changes, the project is still not running and I'm still > > not sure if it's my django app that's the issue or wsgi and my Apache > > configs. :/ > > 1. In WSGIScriptAlias you map your wsgi script (django.wsgi itself) to > the root of your duckling website. In other words your wsgi script > becomes the / which is the slash at the end ofhttp://1.2.3.4/ > > 2. Your Apache config opens up access to the directory in which that > script lives - in other words you create a hole in the entire filesystem > lockdown. > > To gain more info on wsgi scripts try ... > > http://code.google.com/p/modwsgi/wiki/DebuggingTechniques > > Good luck > > Mike > > > > > > > > > > > thanks for the reply back, I do appreciate it... > > > j. > > > On Dec 11, 5:29 pm, Mike Dewhirst wrote: > >> On 12/12/2010 7:14am, jc wrote: > > >>> Apache& mod_wsgi are configured correctly (I've created a hello > >>> world .html apache file and a hello world mod_wsgi application with > >>> no > >>> problems). I know need my Django app to recognize my django.wsgi > >>> file. > >>> What makes me think that it's not recognizing my wsgi file is that I > >>> went into my django.wsgi file I created and completely deleted all of > >>> the code in the file and restarted Apache and it still gives me the > >>> same page (a listing of the files from Django app, not my actual > >>> Django application. Configuring Apache and mod_wsgi went really well > >>> but I'm at a loss of how to fix this. Here are some details instead of > >>> "it's > >>> not working": > > >> You are correct. Apache is not looking at the wsgi script. Have a look > >> at the suggestions below ... before playing with django.wsgi. > > >>> Here is my current django.wsgi file: > > >>> import os > >>> import sys > >>> sys.path.append('/srv/www/duckling.org/store/') > >>> os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ > >>> store/.python- > >>> egg' > >>> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' > >>> import django.core.handlers.wsgi > >>> application = django.core.handlers.wsgi.WSGIHandler() > > >>> I've tried a few different versions of the django.wsgi file > >>> (including > >>> a version like the one over athttp://www.djangoproject.com/). > >>> This version of my wsgi is from here: > >>>http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... > > >>> Also, here is my vhost apache configuration file below. I think these > >>> are > >>> the main files that are suppose to do the job for me. Let me know if > >>> you see any errors in what I'm doing and what else I might do to fix > >>> this. The django app runs fine on the django's built-in development > >>> server so I'm thinking it *might have* something with my paths. > >>> No errors in my apache error.log file as well. It's
Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
On 12/12/2010 10:56am, jc wrote: I've tried to fix my config files and it gives me a 500 error, here is what i see n the logs. I've been told by someone else that they think it's still my mod_wsgi/Apache configuration and not the error that I'm getting in the log about missing modules. Any suggestions? Here is the server error log message and my newly configured files: # # error.log # mod_wsgi (pid=20698): Exception occurred processing WSGI script '/ srv/ www/duckling.org/store/wsgi-scripts/django.wsgi'. Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ wsgi.py", line 230, in __call__ self.load_middleware() File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)) ImproperlyConfigured: Error importing middleware satchmo_store.shop.SSLMiddleware: "No module named satchmo_store.shop.SSLMiddleware I'm at a loss here as to how I find out if the problem lies with mod_wsgi or apache configs or django or satchmo. So, I'm posting here just in case someone might be able to help me out. Without some help this project is as good as doomed as I don't have a lot of skills and I'm learning along the way. The loading middleware error seems straightforward. My guess is the module containing the middleware cannot be found. If you installed Satchmo correctly it will have added itself properly to the Python path and that error wouldn't occur. If you are learning and still need to develop your skills I would recommend using the Django dev server to try it out. hth Mike -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
On 12/12/2010 10:35am, jc wrote: You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lacking a directory for the WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my listing of my files in my project when I go to my address *but* I now get 500 Internal Server Error. I'm not sure if I should trust the logs Always trust the logs. If you know enough about Apache to mistrust the logs then you wouldn't be here. or maybe I've misconfigured something else (either in Apache or in my django.wsgi file)...I had this same issue yesterday 500 error... Also, when you said "Somewhere in your Apache config you have denied access to the entire filesystem", do you mean *Apache* has done this so that it will keep others out of my project (not that I've actually done this somewhere, right?) Somewhere in your Apache config there will be something like this ... # forbid access to the entire filesystem by default Options None AllowOverride None Order deny,allow Deny from all ... which - as the comment says - locks the public out of everything on the server. actually means the root of the server itself. In other words /. The '/>' is not an XML closing tag even though it might look like it. This is why you need to specifically open up public access to htdocs and your wsgi script directory. Incidentally, it is also why your Django code should not be in your your wsgi script directory. If it was Apache could reveal it to the public - which is what I think you were describing earlier. After these changes, the project is still not running and I'm still not sure if it's my django app that's the issue or wsgi and my Apache configs. :/ 1. In WSGIScriptAlias you map your wsgi script (django.wsgi itself) to the root of your duckling website. In other words your wsgi script becomes the / which is the slash at the end of http://1.2.3.4/ 2. Your Apache config opens up access to the directory in which that script lives - in other words you create a hole in the entire filesystem lockdown. To gain more info on wsgi scripts try ... http://code.google.com/p/modwsgi/wiki/DebuggingTechniques Good luck Mike thanks for the reply back, I do appreciate it... j. On Dec 11, 5:29 pm, Mike Dewhirstwrote: On 12/12/2010 7:14am, jc wrote: Apache&mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file is that I went into my django.wsgi file I created and completely deleted all of the code in the file and restarted Apache and it still gives me the same page (a listing of the files from Django app, not my actual Django application. Configuring Apache and mod_wsgi went really well but I'm at a loss of how to fix this. Here are some details instead of "it's not working": You are correct. Apache is not looking at the wsgi script. Have a look at the suggestions below ... before playing with django.wsgi. Here is my current django.wsgi file: import os import sys sys.path.append('/srv/www/duckling.org/store/') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ store/.python- egg' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I've tried a few different versions of the django.wsgi file (including a version like the one over athttp://www.djangoproject.com/). This version of my wsgi is from here: http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... Also, here is my vhost apache configuration file below. I think these are the main files that are suppose to do the job for me. Let me know if you see any errors in what I'm doing and what else I might do to fix this. The django app runs fine on the django's built-in development server so I'm thinking it *might have* something with my paths. No errors in my apache error.log file as well. It's acting as there's no problem at all, which is not the case...the project isn't loading, like I said just a listing of my files and directories of my Django project. Here is my apache config file: ServerAdmin h...@duckling.org ServerName duckling.org ServerAliaswww.duckling.org DocumentRoot /srv/www/duckling.org/store/ # DocumentRoot is where you keep non-django stuff eg., static files # which is served by Apache without needing your Django code DocumentRoot /srv/www/duckling.org/htdocs/ Order Allow,Deny Allow from all # now let the public access anything here AllowOverride None Order deny,allow Allow from all WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/ django.wsgi Order allow,deny Allow
Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
Here's the config I'm using for mod_wsgi: http://drumcoder.co.uk/blog/2009/nov/21/apache-mod_wsgi-config/ Hope that helps, Tim. On 11/12/10 23:35, jc wrote: You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lacking a directory for the WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my listing of my files in my project when I go to my address *but* I now get 500 Internal Server Error. I'm not sure if I should trust the logs or maybe I've misconfigured something else (either in Apache or in my django.wsgi file)...I had this same issue yesterday 500 error... Also, when you said "Somewhere in your Apache config you have denied access to the entire filesystem", do you mean *Apache* has done this so that it will keep others out of my project (not that I've actually done this somewhere, right?) After these changes, the project is still not running and I'm still not sure if it's my django app that's the issue or wsgi and my Apache configs. :/ thanks for the reply back, I do appreciate it... j. On Dec 11, 5:29 pm, Mike Dewhirstwrote: On 12/12/2010 7:14am, jc wrote: Apache&mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file is that I went into my django.wsgi file I created and completely deleted all of the code in the file and restarted Apache and it still gives me the same page (a listing of the files from Django app, not my actual Django application. Configuring Apache and mod_wsgi went really well but I'm at a loss of how to fix this. Here are some details instead of "it's not working": You are correct. Apache is not looking at the wsgi script. Have a look at the suggestions below ... before playing with django.wsgi. Here is my current django.wsgi file: import os import sys sys.path.append('/srv/www/duckling.org/store/') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ store/.python- egg' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I've tried a few different versions of the django.wsgi file (including a version like the one over athttp://www.djangoproject.com/). This version of my wsgi is from here: http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... Also, here is my vhost apache configuration file below. I think these are the main files that are suppose to do the job for me. Let me know if you see any errors in what I'm doing and what else I might do to fix this. The django app runs fine on the django's built-in development server so I'm thinking it *might have* something with my paths. No errors in my apache error.log file as well. It's acting as there's no problem at all, which is not the case...the project isn't loading, like I said just a listing of my files and directories of my Django project. Here is my apache config file: ServerAdmin h...@duckling.org ServerName duckling.org ServerAliaswww.duckling.org DocumentRoot /srv/www/duckling.org/store/ # DocumentRoot is where you keep non-django stuff eg., static files # which is served by Apache without needing your Django code DocumentRoot /srv/www/duckling.org/htdocs/ Order Allow,Deny Allow from all # now let the public access anything here AllowOverride None Order deny,allow Allow from all WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/ django.wsgi Order allow,deny Allow from all Somewhere in your Apache config you have denied access to the entire filesystem to prevent outsiders from hacking in. Your Django code must also be hidden from outsiders so it will live safely in /srv/www/duckling.org/store because you haven't allowed anyone except Apache to see it. Now you need to provide an allowed conduit to your Django code. So make an Apache script alias to map the website root (ie '/') to your Django code. Because you are using mod_wsgi the entry point is your django.wsgi script. So map / to the script: WSGIScriptAlias / /srv/www/duckling.org/store/wsgi-scripts/django.wsgi # and give the public full access - but only to the entry point Order deny,allow Allow from all hth Mike And here are versions of the stack that I'm using, I saw over at the mod_wsgi site that you all would like the versions of what I'm using on the server: Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8 I would remove mod_python if possible thanks, j. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,
Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
I've tried to fix my config files and it gives me a 500 error, here is what i see n the logs. I've been told by someone else that they think it's still my mod_wsgi/Apache configuration and not the error that I'm getting in the log about missing modules. Any suggestions? Here is the server error log message and my newly configured files: # # error.log # mod_wsgi (pid=20698): Exception occurred processing WSGI script '/ srv/ www/duckling.org/store/wsgi-scripts/django.wsgi'. Traceback (most recent call last): File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ wsgi.py", line 230, in __call__ self.load_middleware() File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)) ImproperlyConfigured: Error importing middleware satchmo_store.shop.SSLMiddleware: "No module named satchmo_store.shop.SSLMiddleware I'm at a loss here as to how I find out if the problem lies with mod_wsgi or apache configs or django or satchmo. So, I'm posting here just in case someone might be able to help me out. Without some help this project is as good as doomed as I don't have a lot of skills and I'm learning along the way. Here are my config files. I've went though many different versions, this is my latest: # apache vhost file called duckling.org ServerAdmin h...@duckling.org ServerName duckling.org ServerAlias www.duckling.org DocumentRoot /srv/www/duckling.org/store/ Order Allow,Deny Allow from all Alias /static /srv/www/duckling.org/store/static/ AllowOverride None Order deny,allow Allow from all WSGIScriptAlias / /srv/www/duckling.org/store/wsgi-scripts/ django.wsgi Order deny,allow Allow from all # # django.wsgi file # import os import sys sys.path.append('/srv/www/duckling.org/store') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() # With this current configuration I get a error in my server logs for: ImproperlyConfigured: Error importing middleware satchmo_store.shop.SSLMiddleware: "No module named satchmo_store.shop.SSLMiddleware" Can anyone give me some clues as what I can do next? And if all else fails, what are my alternatives as far as deploying this django app? I've got time to "change plans" at this moment. thanks again for the help! j. On Dec 11, 6:35 pm, jcwrote: > You definitely lost me in some places but you've also cleared some > things up in the process. I also noticed that I had " www/wsgi-scripts>", which is lacking a directory for the > WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my > listing of my files in my project when I go to my address *but* I now > get 500 Internal Server Error. I'm not sure if I should trust the logs > or maybe I've misconfigured something else (either in Apache or in my > django.wsgi file)...I had this same issue yesterday 500 error... > > Also, when you said "Somewhere in your Apache config you have denied > access to the entire filesystem", do you mean *Apache* has done this > so that it will keep others out of my project (not that I've actually > done this somewhere, right?) > > After these changes, the project is still not running and I'm still > not sure if it's my django app that's the issue or wsgi and my Apache > configs. :/ > > thanks for the reply back, I do appreciate it... > > j. > > On Dec 11, 5:29 pm, Mike Dewhirst wrote: > > > > > > > > > On 12/12/2010 7:14am, jc wrote: > > > > Apache& mod_wsgi are configured correctly (I've created a hello > > > world .html apache file and a hello world mod_wsgi application with > > > no > > > problems). I know need my Django app to recognize my django.wsgi > > > file. > > > What makes me think that it's not recognizing my wsgi file is that I > > > went into my django.wsgi file I created and completely deleted all of > > > the code in the file and restarted Apache and it still gives me the > > > same page (a listing of the files from Django app, not my actual > > > Django application. Configuring Apache and mod_wsgi went really well > > > but I'm at a loss of how to fix this. Here are some details instead of > > > "it's > > > not working": > > > You are correct. Apache is not looking at the wsgi script. Have a look > > at the suggestions below ... before playing with django.wsgi. > > > > Here is my current django.wsgi file: > > > > import os > > > import sys > > > sys.path.append('/srv/www/duckling.org/store/') > > > os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ > > > store/.python- > > > egg' > > >
Re: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
You definitely lost me in some places but you've also cleared some things up in the process. I also noticed that I had "", which is lacking a directory for the WSGIScriptAlias. I've fixed that now. *Now*, I no longer get my listing of my files in my project when I go to my address *but* I now get 500 Internal Server Error. I'm not sure if I should trust the logs or maybe I've misconfigured something else (either in Apache or in my django.wsgi file)...I had this same issue yesterday 500 error... Also, when you said "Somewhere in your Apache config you have denied access to the entire filesystem", do you mean *Apache* has done this so that it will keep others out of my project (not that I've actually done this somewhere, right?) After these changes, the project is still not running and I'm still not sure if it's my django app that's the issue or wsgi and my Apache configs. :/ thanks for the reply back, I do appreciate it... j. On Dec 11, 5:29 pm, Mike Dewhirstwrote: > On 12/12/2010 7:14am, jc wrote: > > > Apache& mod_wsgi are configured correctly (I've created a hello > > world .html apache file and a hello world mod_wsgi application with > > no > > problems). I know need my Django app to recognize my django.wsgi > > file. > > What makes me think that it's not recognizing my wsgi file is that I > > went into my django.wsgi file I created and completely deleted all of > > the code in the file and restarted Apache and it still gives me the > > same page (a listing of the files from Django app, not my actual > > Django application. Configuring Apache and mod_wsgi went really well > > but I'm at a loss of how to fix this. Here are some details instead of > > "it's > > not working": > > You are correct. Apache is not looking at the wsgi script. Have a look > at the suggestions below ... before playing with django.wsgi. > > > > > > > > > > > > > Here is my current django.wsgi file: > > > import os > > import sys > > sys.path.append('/srv/www/duckling.org/store/') > > os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ > > store/.python- > > egg' > > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' > > import django.core.handlers.wsgi > > application = django.core.handlers.wsgi.WSGIHandler() > > > I've tried a few different versions of the django.wsgi file > > (including > > a version like the one over athttp://www.djangoproject.com/). > > This version of my wsgi is from here: > >http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... > > > Also, here is my vhost apache configuration file below. I think these > > are > > the main files that are suppose to do the job for me. Let me know if > > you see any errors in what I'm doing and what else I might do to fix > > this. The django app runs fine on the django's built-in development > > server so I'm thinking it *might have* something with my paths. > > No errors in my apache error.log file as well. It's acting as there's > > no problem at all, which is not the case...the project isn't loading, > > like I said just a listing of my files and directories of my Django > > project. Here is my apache config file: > > > > > ServerAdmin h...@duckling.org > > ServerName duckling.org > > ServerAliaswww.duckling.org > > > DocumentRoot /srv/www/duckling.org/store/ > > # DocumentRoot is where you keep non-django stuff eg., static files > # which is served by Apache without needing your Django code > DocumentRoot /srv/www/duckling.org/htdocs/ > > > > > > > Order Allow,Deny > > Allow from all > > > > # now let the public access anything here > > AllowOverride None > Order deny,allow > Allow from all > > > > > > WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/ > > django.wsgi > > > > Order allow,deny > > Allow from all > > > > > > Somewhere in your Apache config you have denied access to the entire > filesystem to prevent outsiders from hacking in. Your Django code must > also be hidden from outsiders so it will live safely in > /srv/www/duckling.org/store because you haven't allowed anyone except > Apache to see it. > > Now you need to provide an allowed conduit to your Django code. So make > an Apache script alias to map the website root (ie '/') to your Django > code. Because you are using mod_wsgi the entry point is your django.wsgi > script. So map / to the script: > WSGIScriptAlias / /srv/www/duckling.org/store/wsgi-scripts/django.wsgi > > # and give the public full access - but only to the entry point > > Order deny,allow > Allow from all > > > hth > Mike > > > > > And here are versions of the stack that I'm using, I saw over at the > > mod_wsgi site that you all would like the versions of what I'm using > > on the server: > > Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch > > mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8 > > I would remove mod_python if possible > > > > > > > > > > > thanks,
Is it possible to specify the html class attribute for a form field?
Thank you in advance for any feedback. Here is what I have {{ form.name }}. I would like to set the class attribute for this form element to "style01". Is this possible? If it is not possible then I have been trying to get this working as well without much luck. I realize that this syntax is incorrect but I'm trying to illustrate what I am trying to do. Is there anyway to access the value of a form field from the template? If the user submits data that does not validate, I do not want them to have to fill out the form twice. I found one discussion suggesting that I make the form's cleaned data available to the view but that feels hackish although I'm not above it! I was just hoping that there was a cleaner way to do this. Thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
On 12/12/2010 7:14am, jc wrote: Apache& mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file is that I went into my django.wsgi file I created and completely deleted all of the code in the file and restarted Apache and it still gives me the same page (a listing of the files from Django app, not my actual Django application. Configuring Apache and mod_wsgi went really well but I'm at a loss of how to fix this. Here are some details instead of "it's not working": You are correct. Apache is not looking at the wsgi script. Have a look at the suggestions below ... before playing with django.wsgi. Here is my current django.wsgi file: import os import sys sys.path.append('/srv/www/duckling.org/store/') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ store/.python- egg' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I've tried a few different versions of the django.wsgi file (including a version like the one over at http://www.djangoproject.com/). This version of my wsgi is from here: http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... Also, here is my vhost apache configuration file below. I think these are the main files that are suppose to do the job for me. Let me know if you see any errors in what I'm doing and what else I might do to fix this. The django app runs fine on the django's built-in development server so I'm thinking it *might have* something with my paths. No errors in my apache error.log file as well. It's acting as there's no problem at all, which is not the case...the project isn't loading, like I said just a listing of my files and directories of my Django project. Here is my apache config file: ServerAdmin h...@duckling.org ServerName duckling.org ServerAlias www.duckling.org DocumentRoot /srv/www/duckling.org/store/ # DocumentRoot is where you keep non-django stuff eg., static files # which is served by Apache without needing your Django code DocumentRoot /srv/www/duckling.org/htdocs/ Order Allow,Deny Allow from all # now let the public access anything here AllowOverride None Order deny,allow Allow from all WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/ django.wsgi Order allow,deny Allow from all Somewhere in your Apache config you have denied access to the entire filesystem to prevent outsiders from hacking in. Your Django code must also be hidden from outsiders so it will live safely in /srv/www/duckling.org/store because you haven't allowed anyone except Apache to see it. Now you need to provide an allowed conduit to your Django code. So make an Apache script alias to map the website root (ie '/') to your Django code. Because you are using mod_wsgi the entry point is your django.wsgi script. So map / to the script: WSGIScriptAlias / /srv/www/duckling.org/store/wsgi-scripts/django.wsgi # and give the public full access - but only to the entry point Order deny,allow Allow from all hth Mike And here are versions of the stack that I'm using, I saw over at the mod_wsgi site that you all would like the versions of what I'm using on the server: Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8 I would remove mod_python if possible thanks, j. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Calling a mssql stored procedure and displaying the result as a datagrid
Hi, > 1. I have a stored procedure in my mssql database server and i would > like to call the procedure in my program with certain parameters.(Is > there a way the results of the stored procedure be represented as a > queryset?) > Read about raw SQL: http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly For MSSQL, you'll probably be passing sql like EXEC s_foo @p=1 and so on. I've not actually used MSSQL SPs with Django, but you might want to make sure your SP has SET NOCOUNT ON, as I've seen that cause problems in the past with other system. > 2. The results returned from the procedure must be represented as a > datagrid with a couple of columns as links and some non database > column say a checkbox. The datagrid must have alternating colors and > a totals row at the end. > Write a view that iterates through your result set and calculates the total. Pass that to a template along with the queryset returned from your original SQL call. http://docs.djangoproject.com/en/dev/topics/http/views/ As for the checkboxes, well, it's all just HTML. Use and a form. http://www.w3schools.com/html/html_forms.asp > 3. Also the stored procedure returns some column's which are numbers > and have to be be represented as a distinct link which redirects to a > distinct pages. > Read about URL generation in Django: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url > 4. whats the simplest way to implement the above requirements?? > > i went through forms and modelforms they are very helpful as you can > print the entire form as a table. isn't there something similar in > django to display a datagrid as i described earlier?? For very simple data browsing: http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/ It won't cover everything you want above, though - you're probably better off writing your own view and template. If it's something you're going to reuse often, consider writing a custom template tag to do it. Cheers, Dan -- Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to move inline into or above fieldsets in django admin?
Well, the template is what controls the ordering of fields. You can create your own template that Django will then use in the admin interface. From there you can control exactly how things are displayed. On Dec 11, 2010 1:30 PM, "mongoose"wrote: > Hi wayne, > > to be honest I've no idea how i'd do that by overriding a template. > > On Dec 11, 7:20 pm, wayne wrote: >> On Dec 11, 8:05 am, mongoose wrote: >> >> >> >> > Hi there, >> >> > Currently I've got a recipe application like this: >> >> > class RecipeAdmin(admin.ModelAdmin): >> > fieldsets = ( >> > ('Recipe Details',{ >> > 'fields': ( >> > ('title', 'slug'),'description', 'difficulty', 'vegetarian', >> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' >> > ) >> > }), >> > ('Cooking Instructions', {'fields': ['instructions']}), >> > ) >> > inlines = [IngredientInline, PhotoInline] >> >> > The problem here is that the Ingredients are being listed after the >> > Cooking Instruction which doesn't really fit. The best would be to >> > have something like this: >> >> > class RecipeAdmin(admin.ModelAdmin): >> > fieldsets = ( >> > ('Recipe Details',{ >> > 'fields': ( >> > ('title', 'slug'),'description', 'difficulty', 'vegetarian', >> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' >> > ) >> > }), >> >> > inlines = [IngredientInline, PhotoInline] >> >> > ('Cooking Instructions', {'fields': ['instructions']}), >> > ) >> >> > Thanks a lot! >> >> I'm not sure if there is an admin setting that will allow you to >> specify this ordering. Either way, you can always override the admin >> template for this particular class. >> >> Read about it here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... >> >> Wayne > > -- > You received this message because you are subscribed to the Google Groups "Django users" group. > To post to this group, send email to django-us...@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. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Apache & mod_wsgi are configured correctly. Need Django to recognize my django.wsgi file.
Apache & mod_wsgi are configured correctly (I've created a hello world .html apache file and a hello world mod_wsgi application with no problems). I know need my Django app to recognize my django.wsgi file. What makes me think that it's not recognizing my wsgi file is that I went into my django.wsgi file I created and completely deleted all of the code in the file and restarted Apache and it still gives me the same page (a listing of the files from Django app, not my actual Django application. Configuring Apache and mod_wsgi went really well but I'm at a loss of how to fix this. Here are some details instead of "it's not working": Here is my current django.wsgi file: import os import sys sys.path.append('/srv/www/duckling.org/store/') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/duckling.org/ store/.python- egg' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() I've tried a few different versions of the django.wsgi file (including a version like the one over at http://www.djangoproject.com/). This version of my wsgi is from here: http://library.linode.com/frameworks/django-apache-mod-wsgi/ubuntu-10... Also, here is my vhost apache configuration file below. I think these are the main files that are suppose to do the job for me. Let me know if you see any errors in what I'm doing and what else I might do to fix this. The django app runs fine on the django's built-in development server so I'm thinking it *might have* something with my paths. No errors in my apache error.log file as well. It's acting as there's no problem at all, which is not the case...the project isn't loading, like I said just a listing of my files and directories of my Django project. Here is my apache config file: ServerAdmin h...@duckling.org ServerName duckling.org ServerAlias www.duckling.org DocumentRoot /srv/www/duckling.org/store/ Order Allow,Deny Allow from all WSGIScriptAlias /django /srv/www/duckling.org/store/wsgi-scripts/ django.wsgi Order allow,deny Allow from all And here are versions of the stack that I'm using, I saw over at the mod_wsgi site that you all would like the versions of what I'm using on the server: Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.5 with Suhosin-Patch mod_python/3.3.1 Python/2.6.5 mod_wsgi/2.8 thanks, j. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to move inline into or above fieldsets in django admin?
Hi wayne, to be honest I've no idea how i'd do that by overriding a template. On Dec 11, 7:20 pm, waynewrote: > On Dec 11, 8:05 am, mongoose wrote: > > > > > Hi there, > > > Currently I've got a recipe application like this: > > > class RecipeAdmin(admin.ModelAdmin): > > fieldsets = ( > > ('Recipe Details',{ > > 'fields': ( > > ('title', 'slug'),'description', > > 'difficulty', 'vegetarian', > > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > > ) > > }), > > ('Cooking Instructions', {'fields': ['instructions']}), > > ) > > inlines = [IngredientInline, PhotoInline] > > > The problem here is that the Ingredients are being listed after the > > Cooking Instruction which doesn't really fit. The best would be to > > have something like this: > > > class RecipeAdmin(admin.ModelAdmin): > > fieldsets = ( > > ('Recipe Details',{ > > 'fields': ( > > ('title', 'slug'),'description', > > 'difficulty', 'vegetarian', > > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > > ) > > }), > > > inlines = [IngredientInline, PhotoInline] > > > ('Cooking Instructions', {'fields': ['instructions']}), > > ) > > > Thanks a lot! > > I'm not sure if there is an admin setting that will allow you to > specify this ordering. Either way, you can always override the admin > template for this particular class. > > Read about it here: > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... > > Wayne -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
running projects on the back of a base URL and having issues with the homepage
Hi there, I've got a base url. http://baseurl.com/ I'm trying to run projects on the back of it. For example http://baseurl.com/mongoose/ The projects run but the URL don't work properly because they all reference the base url. So for 'About Me' page it points to http://baseurl.com/about instead of http://baseurl.com/mongoose/about Is this something i need to change in django or apache? Is what I'm trying to do even possible? 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-us...@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.
Extending AdminSite for custom views
Hello, I am trying to extend AdminSite so I can provide custom views, so far i have this: class MyAdminSite(AdminSite): def get_urls(self): urls = super(self.__class__, self).get_urls() my_urls = patterns('', (r'^myview/$', self.admin_view(myview)) ) return my_urls + urls myadmin = MyAdminSite() admpattern = patterns('', (r'^admin/', include(myadmin.urls)),) It works fine, except for one reason. I don't get any ModelAdmin registered in this admin, because all external apps register it doing admin.site.register(). I figured out do add the registered models from site instance to myadmin through: myadmin._registry = site._registry But it doesn't feel right. Anyone with experience in this could point me out to the most correct answer for this problem? Thank you! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Rendering a field value in a custom way
On Dec 11, 5:49 am, Scooxwrote: > Okay, I *think* I figured out a way to fix this. > > I can add methods such as get_stars to the relevant model. > > Then in that method I can do whatever I like with the string (e.g. > convert it to star symbols). > > Would that be the recommended way to do this? > > Kind Regards > Stephan The "recommended" way would be to use a custom template tag (filter), which you said you did not wish to do. If I understand what you want (and I'm not sure that I do), then you _should_ use a custom filter. It really is not much different--it's simply a Python function that returns rendered content. You can pass strings or objects as the args. It would be better in the long run, because: 1. There is probably less overhead--you are rendering and doing some logic inside the same function call, not separate ones. 2. You can have more specific control over the rendering. 3. You only have to write one method. You can put the logic inside of it that determines what field/object sent it. If you go the model method route, you will have to write the same basic logic for each model. It's just more code to write/upkeep. That said, you can use the model method plan, and do the same thing. I did it before when starting out, but now try to keep model methods strictly those which modify the model, and rendering/display methods in filters, since that is where the rendering happens. Wayne -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Form ChoiceField, initial not working
On Dec 11, 5:08 am, Sævar Öfjörðwrote: > I think you should provide your choices in the form field, not when > creating an instance of the form. Agreed. To create a dynamic form such as this, the best way would probably be to use a custom __init__ function. In your view, when you create your form, you can pass in a 'queryset=' argument that will do this for you. Wayne -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to move inline into or above fieldsets in django admin?
On Dec 11, 8:05 am, mongoosewrote: > Hi there, > > Currently I've got a recipe application like this: > > class RecipeAdmin(admin.ModelAdmin): > fieldsets = ( > ('Recipe Details',{ > 'fields': ( > ('title', 'slug'),'description', > 'difficulty', 'vegetarian', > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > ) > }), > ('Cooking Instructions', {'fields': ['instructions']}), > ) > inlines = [IngredientInline, PhotoInline] > > The problem here is that the Ingredients are being listed after the > Cooking Instruction which doesn't really fit. The best would be to > have something like this: > > class RecipeAdmin(admin.ModelAdmin): > fieldsets = ( > ('Recipe Details',{ > 'fields': ( > ('title', 'slug'),'description', > 'difficulty', 'vegetarian', > 'serves', ('prep_time', 'cooking_time'), 'categories','tags' > ) > }), > > inlines = [IngredientInline, PhotoInline] > > ('Cooking Instructions', {'fields': ['instructions']}), > ) > > Thanks a lot! I'm not sure if there is an admin setting that will allow you to specify this ordering. Either way, you can always override the admin template for this particular class. Read about it here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates Wayne -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django session InvalidOperation
Hard to know from what's shown here, but it seems likely that your database didn't get created properly on the new server. The error suggests that the expire_date column of the django_session table in the MySQL database is of type DECIMAL rather than the expected DATETIME. How did you migrate the database to the new server? It's best to use mysqldump and not simply copy the data files when you're changing MySQL versions. On Dec 11, 12:31 pm, kinderwrote: > I'm stumped... even removing mod_php from the apache config (which is > where I suspected a different mysql shared library), I still get the > same InvalidOperation error. Any suggestions what to try next? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Dump & load: sqlite to poastgres
On Fri, Dec 10, 2010 at 9:17 PM, TomPHwrote: > What is the best practise to migrate the data from sqllite to > postgres? All tries I had till now failed with DB key errors! > > What I did: > > 1) python manage.py dumpdata --indent 3 -n >../dev_data.json (dev. > system) > 2) python manage.py flush (production) > no creation of superusers (but this doesn't make any differne if I > create one or not...) > 3) python manage.py loaddata dev_data.json > > Error: > > Problem installing fixture '../dev_data.json': Traceback (most recent > call last): > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > core/management/commands/loaddata.py", line 172, in handle > obj.save(using=using) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > core/serializers/base.py", line 165, in save > models.Model.save_base(self.object, using=using, raw=True) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/models/base.py", line 500, in save_base > rows = manager.using(using).filter(pk=pk_val)._update(values) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/models/query.py", line 491, in _update > return query.get_compiler(self.db).execute_sql(None) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/models/sql/compiler.py", line 861, in execute_sql > cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/models/sql/compiler.py", line 727, in execute_sql > cursor.execute(sql, params) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/backends/util.py", line 15, in execute > return self.cursor.execute(sql, params) > File "/usr/lib/python2.5/site-packages/Django-1.2.3-py2.5.egg/django/ > db/backends/postgresql/base.py", line 57, in execute > return self.cursor.execute(smart_str(sql, self.charset), > self.format_params(params)) > IntegrityError: ERROR: duplicate key error in Unique-Constraint > »django_content_type_app_label_key« > > UPDATE "django_content_type" SET "name" = 'Address Book', "app_label" > = 'contact', "model" = 'addressbook' WHERE "django_content_type"."id" > = 38 > > > I also dumped app by app and tried to load it - no success! Can > anybody post me the steps it normally should work? Maybe I forgot a > step (clear data or whatever in the target database...)? You're hitting a common, and (now) easily resolved problem. The issue is that the content types table is automatically populated as part of the syncdb process. However, your fixture also contains content types data (since you're dumping the entire database). When you load the fixture into the new database, you get conflicts because the order of creation of content types isn't guaranteed, so your fixture is trying to produce duplicate content type records. The fix is reasonably simple. You need to do two things: 1) Omit content types from your dumped fixture 2) Use natural keys in your fixture. This ensures that any object that references a contenttype (e.g., user permissions) will load them by doing a lookup on the database, rather than just specifying a primary key value. So - your original dump command should look something like: ./manage.py dumpdata --exclude=contenttypes -n --indent=3 Your fixture should then load without incident on your synchronized Postgres database. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to move inline into or above fieldsets in django admin?
Hi there, Currently I've got a recipe application like this: class RecipeAdmin(admin.ModelAdmin): fieldsets = ( ('Recipe Details',{ 'fields': ( ('title', 'slug'),'description', 'difficulty', 'vegetarian', 'serves', ('prep_time', 'cooking_time'), 'categories','tags' ) }), ('Cooking Instructions', {'fields': ['instructions']}), ) inlines = [IngredientInline, PhotoInline] The problem here is that the Ingredients are being listed after the Cooking Instruction which doesn't really fit. The best would be to have something like this: class RecipeAdmin(admin.ModelAdmin): fieldsets = ( ('Recipe Details',{ 'fields': ( ('title', 'slug'),'description', 'difficulty', 'vegetarian', 'serves', ('prep_time', 'cooking_time'), 'categories','tags' ) }), inlines = [IngredientInline, PhotoInline] ('Cooking Instructions', {'fields': ['instructions']}), ) Thanks a lot! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on a hosting service
To use Django with Apache, it would be necessary to install *some* python interpreter into the server. I used Django on our shared hosting site using an .htaccess that called the mod_python handler in Django. However, mod_python was already installed. If they are offering to install mod_wsgi, then absolutely take them up on it. The performance difference between mod_wsgi and pretty much every other Apache arrangement cannot be understated. -Mark On Dec 9, 8:56 pm, Todd Wilsonwrote: > A couple of weeks ago I sent the message quoted below to the list. One > reader (Daniel Roseman) replied and suggested that I might not need to > ask the hosting service to install anything, quoting documentation from > the FastCGI section, but it seemed to me (as explained in my reply on > 11/28/2010) that mod_fastcgi had to be installed, which it isn't (or at > least it's not in /etc/apache2/mods-available/). > > Anyway, I got through to the hosting provider's tech support with my > request and got this reply: > > According to Django requirements (http://packages.debian.org/lenny > /python-django) and our experience there is no need to have > mod_python or mod_wsgi installed on the server. So, you could > try to run Django web site on the server. If any problem arises we > will install the mod_wsgi module. > > I wonder if they are referring to the development server here. Please > correct me if I'm wrong, but I understood from the documentation that a > vanilla installation of Apache would not be sufficient to deploy > production Django applications, except possibly through (old-fashioned) > CGI: some form of integration (mod_wsgi, mod_python, mod_fastcgi, ...) > would be needed. Is that right? > > In any case, they are willing to install mod_wsgi. Not being very > familiar with Apache configuration, can someone tell me how much of the > WSGI configuration mentioned in the Django docs for WSGI deployment > (http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/) can be > done with an .htaccess file, and how much I will have to ask them to do > for me? > > Thanks, > > --Todd > > Todd Wilson wrote, on 11/27/2010 07:20 PM:> I'm helping some friends improve > a portal website they have created > > using PHP, but which would be ideal for Django, in the sense that a lot > > of the work they've already done, and would like to do as they improve > > the site, would be easy to do in Django. They have a hosting contract > > with Intermedia (http://www.intermedia.net/) and would very much like to > > keep it. I've gotten ssh access to their server and went poking around > > a bit, and, although python is available on the server (version 2.5.2), > > there doesn't seem to be any support for WSGI, mod_python, FastCGI, or > > the other deployment options listed in the documentation (at least I > > didn't see them in /etc/apache2/mods-available/), and it doesn't look > > like they support other frameworks (Rails, Drupal, Zope) either. > > > My question: I've always set up my own servers and don't have any > > experience with web hosting; is there a minimal sort of request that I > > could make to Intermedia that, if granted, would make it possible for me > > (and presumably others) to deploy a Django site using their service, or > > should I just try to convince my friends to find a different hosting > > service? It seems like there would be many to choose from: > > > http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts > > > Thanks, > > > --Todd -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Rendering a field value in a custom way
Okay, I *think* I figured out a way to fix this. I can add methods such as get_stars to the relevant model. Then in that method I can do whatever I like with the string (e.g. convert it to star symbols). Would that be the recommended way to do this? Kind Regards Stephan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Form ChoiceField, initial not working
I think you should provide your choices in the form field, not when creating an instance of the form. The form would then be something like this: class StoreLocationHoursForm(BForm): sl_list= [('-', 'Choose Location'), (u'Super City', u'901 PHILADELPHIA STREET')] location = forms.ChoiceField(choices=sl_list, required=True) # rest of fields... The initial keyword when creating an instance of the form is used to select which of the choices is rendered as selected. Haven't tested this though. - Sævar On Dec 9, 11:18 pm, Sector7Bwrote: > Hi, i have a simple form: > class StoreLocationHoursForm(BForm): > location = forms.ChoiceField(required=True) > day = forms.ChoiceField(choices=bagit_constants.dow,required=True) > time_open_hours = > forms.ChoiceField(choices=constants.hours,required=True) > time_open_minutes = > forms.ChoiceField(choices=constants.minutes,required=True) > time_close_hours = > forms.ChoiceField(choices=constants.hours,required=True) > time_close_minutes = > forms.ChoiceField(choices=constants.minutes,required=True) > > there can be many locations, so in my view i loop through them to > create a list of tuples to provide a choices list for location: > Log Output of the list when im done:sl_list= [('-', 'Choose > Location'), (u'Super City', u'901 PHILADELPHIA STREET')] > > the code i use to set initial is the following: > > form = StoreLocationHoursForm(initial={"location":sl_list}) > > However my select is empty when it renders the HTML. > > Thanks for the help in advance, > > j -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Rendering a field value in a custom way
Note: Why do I not to use filters? 1. It's nicer if the designer doesn't always have to put |(...) behind the field name. 2. I do not know how to access the object passed in the filter. E.g. if I use {{rating.stars|muBeautify}} the muBeautify filter would only get a unicode "5", but how would it know which field that is gained from? It needs to know that the values given comes from rating.stars, since it should different results if e.g. rating.percent is used. I could write different filters for each, but then there would be ~ 30 filters for the designer to memorize. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Rendering a field value in a custom way
Hi guys, I want to be able to render a custom field. It's supposed to extend a normal char field. I want to place certain content in front of the field, depending upon the fields value. As an example take a simple field that allows entering a number. Instead of displaying the number, I would like to display star symbols (e.g. entering 5 would return 5 star symbols when rendered in templates). Can I do that by extending the field? I do not want to setup any template extensions, I want the field to act like that naturally. I tried overwriting the field like this: class inPlaceCharField(models.CharField): def __init__(self, *args, **kwargs): self.widget = ReCaptcha self.required = True super(models.CharField, self).__init__(*args, **kwargs) def render(self): return ";;;" def __unicode__(self): return "123" def __str__(self): return "1234" def value_to_string(self, obj): value = self._get_val_from_obj(obj) return "12345" But none of them worked - I always get the field's value rendered. Which function do I need to overwrite? Kind Regards and thanks for your answer in advance Stephan -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.