something I really don't know in using manage.py shell
hi, i am trying to use the manage.py shell, for fast testing of what I would like to do. I have a model like this class Function(models.Model): """Functions that KSK Employee account could use""" name = models.CharField(maxlength=40) url = models.CharField(maxlength=40, default='/') method = models.CharField(maxlength=40, default='index') class Profile(models.Model): """KSK Employee accounts to use this application""" user = models.ForeignKey(User, unique=True) department = models.CharField(maxlength=3, choices=DEPARTMENT_LIST) level = models.CharField(maxlength=2, choices=LEVEL_LIST) functions = models.ManyToManyField(Function, blank=True) when I do in the shell >>>p = Profile.objects.filter(id=1) >>>p [] but when I did this >>>p.department it say AttributeError: '_QuerySet' object has no attribute 'level' is there anything I should know? THanks james --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Do I have to send shopping cart data to every template in my app?
I've created a shopping cart. I want to put something on the top of every page that let's people know how many items they have in their cart. I have a lot of views that don't send any dictionary key's that contain shopping cart info. If I want to do this...do I now have to edit every view return render_to_response line so that they all contain a key that contains my shopping cart info? 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: a question about site framework
Kai: I was worrying about how to use the django database api to do site related queries. I mean how do I simply retrieve articles of a site without having to use the custom query. Harry On Aug 1, 9:36 pm, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > Hi Harry, > > On 8/2/07, gt7658b <[EMAIL PROTECTED]> wrote: > > > > > Kai: > > > Thanks for the suggestions. In this case, my Article will have > > relationship with category, not directly withsite. Will I still be > > able to take advantage of the functions ofsiteframework? > > I don't understand you (well, it's late.. maybe that's the reason). > Your articles have a realtionship with a category and a > category belongs to one-or-more sites. Isn't that what you > wanted? > > Kai --~--~-~--~~~---~--~~ 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: Trouble with installing stockphoto
So I was able to import everything it looks like ok, but when i go to http://localhost/stockphoto/ it is giving me the following error: TemplateSyntaxError at /stockphoto/ Template u'base.html' cannot be extended, because it doesn't exist So I navigate to my installed stockphoto at c:/python25/Lib/site- packages/stockphoto/templates/stockphoto/base.html and sure enough the only thing in it is {% extends "base.html" %} It is trying to extend itself as far as I can tell. Any help on this would be extremely appreciated, Thank you! Rocksteady, Danno~ On Aug 1, 2:17 am, Danno <[EMAIL PROTECTED]> wrote: > I am having a bit of trouble installing stockphoto > (http://www.carcosa.net/jason/software/django/stockphoto/README.html) > > I am wanting to try out just the functionality of the app itself, not > yet integrating it with a current project and am running into a few > errors. Here is my work flow as to how I've set up a new project to > have stockphoto: > > I downloaded the stockphoto-0.2.tar.gz, uncompressed it and have the > folder stockphoto-0.2 in c:/django/stockphoto-0.2 > > command line>cd : c\django > > c\django> manage.py startproject testproject > > from here, I have tried multiple ways toinstallstockphoto as an app > inside the c:/django/testproject/ directory and i just can't get it. > > Any and all help you can give this newbie will be extremely > appreciative. Thank you guys! > > Rocksteady, > Danno~ --~--~-~--~~~---~--~~ 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: understanding request.user
On Aug 1, 9:25 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > ... I just want to understand how > django works for me to learn this framework well. My guess as to the intent of the design is that caching a database backed object in the session wouldn't be a good idea as it can get out of sync with what's in the database. Not all access to the auth_user record will be through the session cached User object. As to the User being loaded on every request, take a look at this line found in django.contrib.auth.middleware: request.__class__.user = LazyUser() If you take a look at the LazyUser object you will see that the User is only loaded when request.user is accessed. Hope that helps (and is accurate :-). Doug Van Horn www.maydigital.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-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: default behavior of django.middleware.transaction.TransactionMiddleware
hi, anyone to clarify this? On Jul 17, 4:54 pm, james_027 <[EMAIL PROTECTED]> wrote: > hi, > > If I use django.middleware.transaction.TransactionMiddleware, is > @transaction.commit_on_success the default behavior? or I should > always call on the python decorators? > > Thanks > james --~--~-~--~~~---~--~~ 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: understanding request.user
hi, > request.user gets created by to OR mapping (from the sql database). > request.session comes from a pickle (serialized to a bytestream). > > Both needs to be done for every request. You could use caching, > but object caching (like for request.user) is not possible up to now. > Just like what you say request.user needs to be done on every request why is it not design to put it in the session ... instead of request.user it should be request.session['user'] ... although request.user is much code friendly, I just want to understand how django works for me to learn this framework well. Isn't session will be done only if there's a change in it? assumming we define SESSION_SAVE_EVERY_REQUEST = False Thanks james --~--~-~--~~~---~--~~ 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: How to Display error messages when is form is not valid?
Nevermindgot it figured out. All I have to do is call 'checkout_form.htm' template again if my form is not valid. And then within my 'checkoutform.htm' template add some if statements to make sure they don't have any errors by using the following line. {% if fo.b_firstname.errors %}What you want to display if an error happens{% endif %} On Aug 1, 8:42 pm, Greg <[EMAIL PROTECTED]> wrote: > I've seen examples from other websites where when a form is submitted > and some of the required fields contain no data. It takes them back > to the same url and displays messages like '*** This field is > required' above the form field. > > I currently have my form setup so that when it's submitted and some > required fields are missing it then takes them to a different url and > display's the error messages. > > > > def checkout(request): > if request.method == 'POST': > f = ContactForm(request.POST) > a = theamount(request) > if f.is_valid(): > request.session['orderdetails'] = { > 'amount': a, > 'card_number': request['card_number'], > 'exp_date': request['exp_date'], > 'b_firstname': request['b_firstname'], > return HttpResponseRedirect('/rugs/cart/success') > else: > return render_to_response('error.html', {'e': > f.errors}) > else: > f = ContactForm(auto_id='%s') > return render_to_response('checkout_form.html', {'fo': f, 'o': > request.session['cart'], 'p': theamount(request), 'spad': > request.session['pad']}) > > /// > > How do I show the error messages on the same page which in this case > is checkout_form.html? > > 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 Display error messages when is form is not valid?
I've seen examples from other websites where when a form is submitted and some of the required fields contain no data. It takes them back to the same url and displays messages like '*** This field is required' above the form field. I currently have my form setup so that when it's submitted and some required fields are missing it then takes them to a different url and display's the error messages. def checkout(request): if request.method == 'POST': f = ContactForm(request.POST) a = theamount(request) if f.is_valid(): request.session['orderdetails'] = { 'amount': a, 'card_number': request['card_number'], 'exp_date': request['exp_date'], 'b_firstname': request['b_firstname'], return HttpResponseRedirect('/rugs/cart/success') else: return render_to_response('error.html', {'e': f.errors}) else: f = ContactForm(auto_id='%s') return render_to_response('checkout_form.html', {'fo': f, 'o': request.session['cart'], 'p': theamount(request), 'spad': request.session['pad']}) /// How do I show the error messages on the same page which in this case is checkout_form.html? 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: a question about site framework
Hi Harry, On 8/2/07, gt7658b <[EMAIL PROTECTED]> wrote: > > Kai: > > Thanks for the suggestions. In this case, my Article will have > relationship with category, not directly with site. Will I still be > able to take advantage of the functions of site framework? I don't understand you (well, it's late.. maybe that's the reason). Your articles have a realtionship with a category and a category belongs to one-or-more sites. Isn't that what you wanted? Kai --~--~-~--~~~---~--~~ 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: a question about site framework
Kai: Thanks for the suggestions. In this case, my Article will have relationship with category, not directly with site. Will I still be able to take advantage of the functions of site framework? Harry On Jul 31, 9:45 pm, "Kai Kuehne" <[EMAIL PROTECTED]> wrote: > ManyToManyField maybe is way better. Sorry, its late. --~--~-~--~~~---~--~~ 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: Including view in a template
On 8/1/07, sagi s <[EMAIL PROTECTED]> wrote: > Not clear on what you mean by "more robust views". Can you please > elaborate? Write views which select more data. > Regarding custom template tags, I guess I expect many users to want to > use django this way, so I think that having a "load_view" template > element would be useful. Don't you agree? Not really, because this sort of thing is precisely what custom template tags are for. Think of the view as the primary "thing" that happens when a user hits a particular URL, and focus the view on that thing. Let's take a simple example: a news site. Now, the detail page for a story on the news site obviously needs to focus on one particular thing: retrieving and returning the story. But there are many other things you'd probably want to do as part of the presentation of that story, including displaying a list of latest stories published, a list of comments associated with the story, etc., etc. Because they're aspects of how the "thing" -- the story retrieved by the view -- is presented, they belong in the presentation layer and should be handled by template tags, not by some system for going and hitting huge numbers of views (which, by definition, would involve corresponding numbers of full request/response cycles -- a horribly inefficiency) just to build up what is, essentially, presentation. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: Can a ManyToManyField only shows certain records in an admin using edit_inline?
Anybody? On Aug 1, 2:49 pm, Greg <[EMAIL PROTECTED]> wrote: > Ok..does anybody know what's wrong with this attempt at trying to get > the 'limit-choices_to' to work? > > class Choice(models.Model): > choice = models.ForeignKey(Collection, edit_inline=models.TABULAR, > num_in_admin=5) > size = models.ForeignKey(Size, core=True) > price = models.ForeignKey(Price, core=True) > > class Style(models.Model): > name = models.CharField(maxlength=200, core=True) > color = models.CharField(maxlength=100) > image = models.ImageField(upload_to='site_media/') > theslug = models.SlugField(prepopulate_from=('name',)) > manufacturer = models.ForeignKey(Manufacturer) > sandp = models.ManyToManyField(Choice, limit_choices_to = > {'choice': get_choices(self)}) > collection = models.ForeignKey(Collection, > edit_inline=models.TABULAR, num_in_admin=6) > > def get_choices(self, style_name): > g = Choice.objects.filter(pk=style_name.collection) > return g > > Thanks > > On Aug 1, 11:09 am, Greg <[EMAIL PROTECTED]> wrote: > > > We'll I kinda got it to work. I added the following > > (limit_choice_to): > > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > > 2}) > > > /// > > > That works fine. However, I obviously want to take out the '2'. I > > tried the following but it does not seem to work: > > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > > collection.id}) > > > > > > I guess I need to know how do I get the id for the current collection > > that I'm adding the style to? > > > Thanks > > > On Aug 1, 2:17 am, Will McCutchen <[EMAIL PROTECTED]> wrote: > > > > > Is there anyway that I can have the 'sandp' Field only > > > > show choices that are tied to that collection? > > > > Try using the limit_choices_to argument to > > > ManyToManyField:http://www.djangoproject.com/documentation/model-api/#many-to-many-re... > > > > Hope this helps, > > > > Will. --~--~-~--~~~---~--~~ 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: Including view in a template
Another option is to use AJAX to populate the "building block" areas. e.g. (Using JQuery) $(document).ready(function() { $('#block1').load('/views/list_users'); $('#block2').load('/views/latest_articles'); }); ... ... -Eric Florenzano On Aug 1, 11:34 am, sagi s <[EMAIL PROTECTED]> wrote: > I am trying to find a way to include a view in a template. The view > generates an html snippet based on a DB query + another template. In > pseudocode what I am trying to achieve is: > > frontpage_template.html: > {{% include header.html %}} > {{% load /views/list_users %}} > {{% load /views/latest_articles %}} > ... > > I tried loading a template instead and have that template issue an > Ajax Updater request to a view upon loading but it seems like an > overkill. > > Any suggestions? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Admin & Models
Actually my question is two fold, most likely due to brain farts on my end. I'm relatively a newbie to Django, so please bear with me. Here's my scenario. I have this for my relationships: Company->Dept->Sub-Dept->Employees->Roles "->" represents a one-to-many relationship. Problem #1: If I do something like this: Class Company(models.Model): name... Class Dept(models.Model): company = ForeignKey(Company) name... Class Sub-Dept(models.Model): dept = ForeignKey(Dept) name... Class Employee(models.Model): sub-dept = ForeignKey(Sub-Dept) first_name... Class Admin: list_display = ( 'first_name', 'last_name', 'sub-dept', ) The problem is when I go into the admin screen and view employees, there is no way of displaying the company and dept. info next to the name of the employee. How can I accomplish that? Problem #2: This kinda arises from my efforts trying to fix Problem #1. I changed my code like so: . . Class Employee(models.Model): company = ForeignKey(Company) dept= ForeignKey(Dept) sub-dept = ForeignKey(Sub-Dept) first_name... Class Admin: list_display = ( 'first_name', 'last_name', 'company', 'dept', 'sub-dept', ) Now the problem is when I add an employee, I have to add some kind of validation to the admin interface that checks whether the sub-dept, dept and company match. My main issue is where can I add this validation so that it is reflected in the admin interface? Thanks in advance for the pointers. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
i18n in different template languages
Hi, I wonder if it is possible to use i18n machinery with different templates systems? Let me describe what I mean: I've started playing with Django few days ago, I just wanted to see what it offers. I know ZPT templates from Zope, so I though I could use them instead of learning new template system. I tried both implementations, (zpt - http://www.zope.org/Members/shh/DjangoPageTemplates and simpletal - http://www.agmweb.ca/blog/andy/1957/), they are no perfect, but it is possible to use them. But I couldn't go through i18n, as it's not implemented in nor of them. I wonder if it's possible to use zope.i18n module in here, has anybody tried this? Or maybe there is some another method, maybe some django middleware? Your FAQ says: "There's nothing about Django that requires using the template language, so if you're attached to ZPT, Cheetah, or whatever, feel free to use those." I wonder if another templates, like Mako, Cheetah or any else can use Django i18n? Well, if not, You probably should add something like "But forget about i18n" ;) regards H. Berbelek --~--~-~--~~~---~--~~ 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: Apache + mod_python (noob django/python/apache) import error in website url file
FIXED!! (mostly) Changed my httpd.conf from: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonInterpreter my_django PythonDebug On PythonPath "['/home/shawn/myCode/intertubewaypoint/'] + sys.path" To: SetHandler python-program PythonPath "['/home/shawn/myCode/intertubewaypoint/', '/home/ shawn/myCode/'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonInterpreter my_django PythonDebug On And my urls.py from what was previously posted to: urlpatterns = patterns('', (r'^blog/(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/ (? P[-\w]+)/$', 'django.views.generic.date_based.object_detail', dict(blog_dict, slug_field='slug')), (r'^blog/?$' 'django.views.generic.date_based.archive_index', blog_dict), # Uncomment this for admin: (r'^admin/', include('django.contrib.admin.urls')), ) Now I get a 404 for intertubewaypoint.com (expected since I don't have a root index page yet) and I can get to my admin site. I get a 404 for blog as well (also expected). Time to get to work :) On Aug 1, 3:21 pm, bhamdeveloper <[EMAIL PROTECTED]> wrote: > Here is my urls.py: > > from django.conf.urls.defaults import * > from intertubewaypoint.blog.models import Entry > > blog_dict = { > 'queryset': Entry.objects.all(), > 'date_field': 'pub_date', > > } > > urlpatterns = patterns('', > (r'^intertubewaypoint/', include('intertubewaypoint.urls')), > (r'^blog/(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(? > P[-\w]+)/$', 'django.views.generic.date_based.object_detail', > dict(blog_dict, slug_field='slug')), > (r'^blog/?$' 'django.views.generic.date_based.archive_index', > blog_dict), > > # Uncomment this for admin: > (r'^admin/', include('django.contrib.admin.urls')), > ) > > On Aug 1, 3:02 pm, bhamdeveloper <[EMAIL PROTECTED]> wrote: > > > > > The /home/shawn/myCode/intertubewaypoint does have my urls.py file in > > it. They way I have my project currently setup is that > > intertubewaypoint is my project directory, and I will have > > applications under there (ex: intertubewaypoint/blog, > > intertubewaypoint/photos, etc.). I want to have intertubewaypoint as > > my root and have a single base template that is shown when you go > > tohttp://intertubewaypoint.comandthen have links to take you to the > > projects. So, in my project directory I have __init__.py, > > settings.py, urls.py, manage.py, (plus corresponding .pyc files) and > > then a directory called blog that has __init__.py, models.py, views.py > > (plus corresponding pyc and pyo files). > > > Anyway, I tried your suggestion and then got a different error, this > > one a plain black and white text output that said: > > Mod_python error: "PythonHandler django.core.handlers.modpython" > > Traceback (most recent call last): > > File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line > > 299, in HandlerDispatch > >result = object(req) > > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > > handlers/modpython.py", line 178, in handler > > return ModPythonHandler()(req) > > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > > handlers/modpython.py", line 146, in __call__ > > self.load_middleware() > > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > > handlers/base.py", line 22, in load_middleware > > for middleware_path in settings.MIDDLEWARE_CLASSES: > > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > > __init__.py", line 28, in __getattr__ > > self._import_settings() > > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > > __init__.py", line 57, in _import_settings > > self._target = Settings(settings_module) > > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > > __init__.py", line 85, in __init__ > > raise EnvironmentError, "Could not import settings '%s' (Is it on > > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, > > e) > > > EnvironmentError: Could not import settings 'settings' (Is it on > > sys.path? Does it have syntax errors?): No module named settings > > > When I reverted back, I get the previous error from django: > > > ImportError at / > > No module named intertubewaypoint.urls > > Request Method: GET > > Request URL:http://intertubewaypoint.com/ > > Exception Type: ImportError > > Exception Value: No module named intertubewaypoint.urls > > Exception Location: /usr/lib/python2.4/site-packages/django_src/django/ > > core/urlresolvers.py in _get_urlconf_module, line 251 > > Python Executable: /usr/bin/python > > Python Version: 2.4.3 > > > Does django need a specific path-to-urls or something that I am > > missing, maybe in the settings file? > > > On Aug 1, 2:05 pm, Emanuele Pucciarelli <[EMAIL PROTECTED]> wrote: > > > > Hello,
equality weirdness
I was writing some unit tests for a model in which I'd written a custom __cmp__ method and got a strange result. Is it a bug, feature, or just something to warn people about. django.db.models.Model defines __eq__ and __ne__ based on PK identity. That means that all model objects are == to one another until they've been saved in the database because their PKs don't get set until they're saved. In my case, >>> name1 < name2 and name2 > name1 True >>> name1 != name2 False Is it worth it to check if the PK exists in the equality check, or have I just hit something that's not likely to ever surface in the real world? 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-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 apache2 path problem
Read my comments at: http://groups.google.com/group/django-users/browse_frm/thread/24deb095a2b2e450/1c982558d464017a The problem is caused by fact that manage.py effectively adds parent directory and directory of site (by virtue of it being current working directory). Thus it allows these things. To fix you need to also add site directory to PythonPath. Graham On Aug 1, 10:18 pm, stereoit <[EMAIL PROTECTED]> wrote: > Well, problem was (of course) on my side. After struggling with this > problem for a day or two I just opened python on my laptop and typed > import syslog > > and it worked, so there is standard python module syslog included > which of course does not have settings. So renaming the project to > syslogviewer solved the problem. So far mod_python works ok. > > so final http config is as this: > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE syslogviewer.settings > PythonPath "['/srv/code/'] + sys.path" > > > where syslogviewer is directory created by "django-admin.py > startproject syslogviewer" run from /srv/code/ directory. > > I then run into problems with statements like: > from models import * > in views.py of various applications inside the syslogviewer project > and I had to change it to: > from syslogviewer.filters.models import * > to make it work. > > Weird is it worked with django-admin.py runserver and not under apache > +mod_python. Now I'm bit confused about how to make applications > decoupled from project as for now I have this kind of string hardcoded > everywhere. > > Anyway, thanks for help, very appreciated! > > Robert > > On Jul 31, 12:25 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > On Jul 31, 5:24 pm, Giorgio Salluzzo <[EMAIL PROTECTED]> > > wrote: > > > > I know very well this problem because in my company we had the same > > > some months ago. > > > > I investigated a lot also on modpython list and it is a known "bug| > > > strange behavior", you can find threads really old about it. > > > Huh. What bug, strange behaviour inmod_python? What old threads? > > > Older versions ofmod_pythondid have some module importing issues but > > the OP is using latest version. > > > Looking again at the original error, the problem possibly turns out to > > be more subtle. > > > What it may come down to is a bad choice of site name. The name they > > have chosen is 'syslog' which clashes with a standard Python module of > > the same name. The result of this may be the same as saying: > > > >>> import syslog > > >>> import syslog.settings > > > Traceback (most recent call last): > > File "", line 1, in ? > > ImportError: No module named settings > > > Ifmod_pythonhas indirectly caused the standard 'syslog' module to be > > imported even before sys.pathis adjusted, when Django goes to import > > 'syslog.settings', Python will see that 'syslog' is already imported > > and try to import 'settings' as a sub module from the 'syslog'. > > Problem is it will not exist and 'syslog' isn't a package so it would > > also fail in attempt to import 'settings' from a package directory for > > standard 'syslog' module. > > > Thus, I'd probably suggest a different name be chosen for the site > > than 'syslog'. > > > > Because of it we changed to the fastest and "problems free" modwsgi. > > > In this casemod_wsgimay not have helped. If the recipe in the > >mod_wsgidocumentation was followed and site parent directory was > > appended to sys.paththen the standard Python 'syslog' module would > > again have been found rather that the user package. Same problem would > > then ensue as standard 'syslog' module doesn't obviously have a > > submodule called 'settings'. > > > Themod_wsgirecipe could be changed to use: > > > sys.path.insert(0, "/some/path") > > > On still has to be very careful about the name chosen for a site > > though and reversing the directory search order could cause problems > > in itself as any code wanting the standard 'syslog' module would now > > accidentally pick up the site package. > > > This raises a general question of whether one should always put > > additional module directories at the start or end of sys.path. > > > It may be worthwhile for the Django documentation to state that one > > should never choose a site name which clashes with any standard Python > > module or common third party software. This could be a source of a lot > > of strange problems otherwise. > > > Graham > > > >www.modwsgi.org > > > > In the wiki page you can find also a Django page. > > > > On Jul 30, 3:18 pm,stereoit<[EMAIL PROTECTED]> wrote: > > > > > Hi, I'm having problem withmod_python. > > > > > EnvironmentError: Could not import settings 'syslog.settings' (Is it > > > > on sys.path? Does it have syntax errors?): No module named settings > > > > > > > > > I've developed small app for viewing syslog messages and it runs fine > > > > with
Re: Distinct rows by a column field?
Combine values() and distinct(): AccessLog.objects.values('key').distinct() http://www.djangoproject.com/documentation/db-api/#values-fields --~--~-~--~~~---~--~~ 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: Apache + mod_python (noob django/python/apache) import error in website url file
Here is my urls.py: from django.conf.urls.defaults import * from intertubewaypoint.blog.models import Entry blog_dict = { 'queryset': Entry.objects.all(), 'date_field': 'pub_date', } urlpatterns = patterns('', (r'^intertubewaypoint/', include('intertubewaypoint.urls')), (r'^blog/(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(? P[-\w]+)/$', 'django.views.generic.date_based.object_detail', dict(blog_dict, slug_field='slug')), (r'^blog/?$' 'django.views.generic.date_based.archive_index', blog_dict), # Uncomment this for admin: (r'^admin/', include('django.contrib.admin.urls')), ) On Aug 1, 3:02 pm, bhamdeveloper <[EMAIL PROTECTED]> wrote: > The /home/shawn/myCode/intertubewaypoint does have my urls.py file in > it. They way I have my project currently setup is that > intertubewaypoint is my project directory, and I will have > applications under there (ex: intertubewaypoint/blog, > intertubewaypoint/photos, etc.). I want to have intertubewaypoint as > my root and have a single base template that is shown when you go > tohttp://intertubewaypoint.comand then have links to take you to the > projects. So, in my project directory I have __init__.py, > settings.py, urls.py, manage.py, (plus corresponding .pyc files) and > then a directory called blog that has __init__.py, models.py, views.py > (plus corresponding pyc and pyo files). > > Anyway, I tried your suggestion and then got a different error, this > one a plain black and white text output that said: > Mod_python error: "PythonHandler django.core.handlers.modpython" > Traceback (most recent call last): > File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line > 299, in HandlerDispatch >result = object(req) > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > handlers/modpython.py", line 178, in handler > return ModPythonHandler()(req) > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > handlers/modpython.py", line 146, in __call__ > self.load_middleware() > File "/usr/lib/python2.4/site-packages/django_src/django/core/ > handlers/base.py", line 22, in load_middleware > for middleware_path in settings.MIDDLEWARE_CLASSES: > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > __init__.py", line 28, in __getattr__ > self._import_settings() > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > __init__.py", line 57, in _import_settings > self._target = Settings(settings_module) > File "/usr/lib/python2.4/site-packages/django_src/django/conf/ > __init__.py", line 85, in __init__ > raise EnvironmentError, "Could not import settings '%s' (Is it on > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, > e) > > EnvironmentError: Could not import settings 'settings' (Is it on > sys.path? Does it have syntax errors?): No module named settings > > When I reverted back, I get the previous error from django: > > ImportError at / > No module named intertubewaypoint.urls > Request Method: GET > Request URL:http://intertubewaypoint.com/ > Exception Type: ImportError > Exception Value: No module named intertubewaypoint.urls > Exception Location: /usr/lib/python2.4/site-packages/django_src/django/ > core/urlresolvers.py in _get_urlconf_module, line 251 > Python Executable: /usr/bin/python > Python Version: 2.4.3 > > Does django need a specific path-to-urls or something that I am > missing, maybe in the settings file? > > On Aug 1, 2:05 pm, Emanuele Pucciarelli <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > >PythonPath "['/home/shawn/myCode/intertubewaypoint/'] + sys.path" > > > Your modules should live right below the PythonPath. If your urls.py > > file is at /home/shawn/myCode/intertubewaypoint/urls.py, then that > > line should probably read > > > PythonPath "['/home/shawn/myCode'] + sys.path" > > > Regards, > > > -- > > Emanuele- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
related_name
how can I change the "related_name" value in a ForeignKey field dynamically at model creation time? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: pydev
Hi As I said earlier i don't have (and don't remember) these settings. But you're right - it was in eclipse.ini. Now I use Eclipse Europa and Java 6 on Kubuntu (32 bit) and I don't have any errors (even null references mentioned by Nimrod). On 31 Lip, 22:19, "Kevin Menard" <[EMAIL PROTECTED]> wrote: > On 7/31/07, eXt <[EMAIL PROTECTED]> wrote: > > > > > I currently use Eclipse Europa with PyDev and it works fine. Earlier I > > worked with Eclipse 3.2 and IIRC I had some problems with lock ups but > > then I changed Eclipse start parameters and it solved my problem. So > > my advice is to upgrade your Eclipse or to read somewhere about > > parameters in Eclipse's start script. I don't remember these settings > > now, sorry. > > Interesting. The PyDev author has noted these problems: > > http://pydev.blogspot.com/2007/07/problems-in-pydev-136.htmlhttp://pydev.blogspot.com/2007/07/pydev-137-and-138.html > > Whatever changes you made to eclipse are likely in the eclipse.ini > file. If you post that, we might be able to see what it is that you > changed. > > -- > Kevin --~--~-~--~~~---~--~~ 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: Apache + mod_python (noob django/python/apache) import error in website url file
The /home/shawn/myCode/intertubewaypoint does have my urls.py file in it. They way I have my project currently setup is that intertubewaypoint is my project directory, and I will have applications under there (ex: intertubewaypoint/blog, intertubewaypoint/photos, etc.). I want to have intertubewaypoint as my root and have a single base template that is shown when you go to http://intertubewaypoint.com and then have links to take you to the projects. So, in my project directory I have __init__.py, settings.py, urls.py, manage.py, (plus corresponding .pyc files) and then a directory called blog that has __init__.py, models.py, views.py (plus corresponding pyc and pyo files). Anyway, I tried your suggestion and then got a different error, this one a plain black and white text output that said: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.4/site-packages/django_src/django/core/ handlers/modpython.py", line 178, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django_src/django/core/ handlers/modpython.py", line 146, in __call__ self.load_middleware() File "/usr/lib/python2.4/site-packages/django_src/django/core/ handlers/base.py", line 22, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/usr/lib/python2.4/site-packages/django_src/django/conf/ __init__.py", line 28, in __getattr__ self._import_settings() File "/usr/lib/python2.4/site-packages/django_src/django/conf/ __init__.py", line 57, in _import_settings self._target = Settings(settings_module) File "/usr/lib/python2.4/site-packages/django_src/django/conf/ __init__.py", line 85, in __init__ raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings When I reverted back, I get the previous error from django: ImportError at / No module named intertubewaypoint.urls Request Method: GET Request URL: http://intertubewaypoint.com/ Exception Type: ImportError Exception Value: No module named intertubewaypoint.urls Exception Location: /usr/lib/python2.4/site-packages/django_src/django/ core/urlresolvers.py in _get_urlconf_module, line 251 Python Executable: /usr/bin/python Python Version: 2.4.3 Does django need a specific path-to-urls or something that I am missing, maybe in the settings file? On Aug 1, 2:05 pm, Emanuele Pucciarelli <[EMAIL PROTECTED]> wrote: > Hello, > > >PythonPath "['/home/shawn/myCode/intertubewaypoint/'] + sys.path" > > Your modules should live right below the PythonPath. If your urls.py > file is at /home/shawn/myCode/intertubewaypoint/urls.py, then that > line should probably read > > PythonPath "['/home/shawn/myCode'] + sys.path" > > Regards, > > -- > Emanuele --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
related_name
how can I change the "related_name" value in a ForeignKey field dynamically at model creation time? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: Including view in a template
Not clear on what you mean by "more robust views". Can you please elaborate? Regarding the term "views", I do mean actually invoking the python function via the url routing system. I would settle for calling a regular python function that returns some html snippet but I think the existing views would just work fine. Regarding custom template tags, I guess I expect many users to want to use django this way, so I think that having a "load_view" template element would be useful. Don't you agree? Cheers, Sagi On Aug 1, 10:29 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/1/07, sagi s <[EMAIL PROTECTED]> wrote: > > > I realize that this is an option but it seems to me more natural to > > control the content from the template so a designer can build views > > using "lego-blocks", without having to tweak the view. > > You either want: > > 1. More robust views, or > 2. Some custom template tags which allow your template authors to > access the things they want to pull in. > > Using the term "views" here to refer to both "the Python function to > which the URL is routed" and "some piece of content I want in a > template" is also likely to end up in severe confusion... > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: Can a ManyToManyField only shows certain records in an admin using edit_inline?
Ok..does anybody know what's wrong with this attempt at trying to get the 'limit-choices_to' to work? class Choice(models.Model): choice = models.ForeignKey(Collection, edit_inline=models.TABULAR, num_in_admin=5) size = models.ForeignKey(Size, core=True) price = models.ForeignKey(Price, core=True) class Style(models.Model): name = models.CharField(maxlength=200, core=True) color = models.CharField(maxlength=100) image = models.ImageField(upload_to='site_media/') theslug = models.SlugField(prepopulate_from=('name',)) manufacturer = models.ForeignKey(Manufacturer) sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': get_choices(self)}) collection = models.ForeignKey(Collection, edit_inline=models.TABULAR, num_in_admin=6) def get_choices(self, style_name): g = Choice.objects.filter(pk=style_name.collection) return g Thanks On Aug 1, 11:09 am, Greg <[EMAIL PROTECTED]> wrote: > We'll I kinda got it to work. I added the following > (limit_choice_to): > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > 2}) > > /// > > That works fine. However, I obviously want to take out the '2'. I > tried the following but it does not seem to work: > sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': > collection.id}) > > > > I guess I need to know how do I get the id for the current collection > that I'm adding the style to? > > Thanks > > On Aug 1, 2:17 am, Will McCutchen <[EMAIL PROTECTED]> wrote: > > > > Is there anyway that I can have the 'sandp' Field only > > > show choices that are tied to that collection? > > > Try using the limit_choices_to argument to > > ManyToManyField:http://www.djangoproject.com/documentation/model-api/#many-to-many-re... > > > Hope this helps, > > > Will. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cascading delete and generic relations
I think I am confused about how to use generic relations properly - when I delete something, cascading delete is not happening as expected. Here are my models: class Permission(models.Model): name = models.CharField(maxlength=32) content_type = models.ForeignKey(ContentType, null=True) object_id = models.PositiveIntegerField(null=True) content_object = generic.GenericForeignKey() class Subject(models.Model): name = models.CharField(maxlength=32) perms = generic.GenericRelation(Permission) class Group(models.Model): name = models.CharField(maxlength=32) perms = models.ManyToManyField(Permission, null=True) (The goal is that a group can have permissions, and each permission pertains to a subject object, but the subject object can be one of many different types.) In my test scenario, I add two subjects (s1 and s2), two permissions referring to these subjects (p1->s1, p2->s2), and one group (g1) that is assigned both permissions. So far so good. When I delete the second subject (s2), things mostly happen as expected: Subject.objects.all() shows only s1 Permission.objects.all() shows only p1 g1.perms.all() shows only p1 However, the database table that contains the relationships between Group and Permission still has rows for both permissions (shown using sqlite3 and .dump): CREATE TABLE "test_group_perms" ( "id" integer NOT NULL PRIMARY KEY, "group_id" integer NOT NULL REFERENCES "test_group" ("id"), "permission_id" integer NOT NULL REFERENCES "test_permission" ("id"), UNIQUE ("group_id", "permission_id") ); INSERT INTO "test_group_perms" VALUES(1, 1, 1); INSERT INTO "test_group_perms" VALUES(2, 1, 2); CREATE INDEX "test_permission_content_type_id" ON "test_permission" ("content_type_id"); COMMIT; This seems mostly harmless, except that when I create a new subject (s3) and associate it with a new permission (p3), my group g1 now has permission p3 even though it was never explicitly assigned that permission: >>> g1.perms.all() [, ] Do I need to somehow clean up the "test_group_perms" table when I delete a subject? Or am I coding my modules incorrectly? I am using the SVN version of Django trunk, updated 7/31/2007. Thanks for any help! Jon --~--~-~--~~~---~--~~ 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: Including view in a template
On 8/1/07, sagi s <[EMAIL PROTECTED]> wrote: > I realize that this is an option but it seems to me more natural to > control the content from the template so a designer can build views > using "lego-blocks", without having to tweak the view. You either want: 1. More robust views, or 2. Some custom template tags which allow your template authors to access the things they want to pull in. Using the term "views" here to refer to both "the Python function to which the URL is routed" and "some piece of content I want in a template" is also likely to end up in severe confusion... -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Windows XP optimization tricks
Windows XP tips and tricks http://windowsxpsp2pro.blogspot.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-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: Including view in a template
Thanks for the quick reply! I realize that this is an option but it seems to me more natural to control the content from the template so a designer can build views using "lego-blocks", without having to tweak the view. Cheers, Sagi On Aug 1, 10:01 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > In the view.py code that you have calling your > frontpage_template.html, you should put your code to query the > database and generate your user list and articles. You would then > pass these to your html template via: > > return render_to_response('frontpage_template.html', > {'list_users':list_users,'latest_articles':latest_articles}) > > On Aug 1, 2:34 pm, sagi s <[EMAIL PROTECTED]> wrote: > > > I am trying to find a way to include a view in a template. The view > > generates an html snippet based on a DB query + another template. In > > pseudocode what I am trying to achieve is: > > > frontpage_template.html: > > {{% include header.html %}} > > {{% load /views/list_users %}} > > {{% load /views/latest_articles %}} > > ... > > > I tried loading a template instead and have that template issue an > > Ajax Updater request to a view upon loading but it seems like an > > overkill. > > > Any suggestions? --~--~-~--~~~---~--~~ 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: Apache + mod_python (noob django/python/apache) import error in website url file
Hello, > PythonPath "['/home/shawn/myCode/intertubewaypoint/'] + sys.path" Your modules should live right below the PythonPath. If your urls.py file is at /home/shawn/myCode/intertubewaypoint/urls.py, then that line should probably read PythonPath "['/home/shawn/myCode'] + sys.path" Regards, -- Emanuele --~--~-~--~~~---~--~~ 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: Including view in a template
In the view.py code that you have calling your frontpage_template.html, you should put your code to query the database and generate your user list and articles. You would then pass these to your html template via: return render_to_response('frontpage_template.html', {'list_users':list_users,'latest_articles':latest_articles}) On Aug 1, 2:34 pm, sagi s <[EMAIL PROTECTED]> wrote: > I am trying to find a way to include a view in a template. The view > generates an html snippet based on a DB query + another template. In > pseudocode what I am trying to achieve is: > > frontpage_template.html: > {{% include header.html %}} > {{% load /views/list_users %}} > {{% load /views/latest_articles %}} > ... > > I tried loading a template instead and have that template issue an > Ajax Updater request to a view upon loading but it seems like an > overkill. > > Any suggestions? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Including view in a template
I am trying to find a way to include a view in a template. The view generates an html snippet based on a DB query + another template. In pseudocode what I am trying to achieve is: frontpage_template.html: {{% include header.html %}} {{% load /views/list_users %}} {{% load /views/latest_articles %}} ... I tried loading a template instead and have that template issue an Ajax Updater request to a view upon loading but it seems like an overkill. Any suggestions? --~--~-~--~~~---~--~~ 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: How to get selected value set in newforms
Hi, On 8/1/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > if choices=(("a", "Letter A",) ... > > you set initial to "a". Simple, isn't it? No, it isn't. It simply doesn't work with ModelMultipleChoiceField. > Thomas Kai --~--~-~--~~~---~--~~ 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: How to get selected value set in newforms
I must be missing something here because when I change the statement to status = forms.ChoiceField(required=False, choices=statlist, initial="choice3") it still displays the 1st record in the list when I am trying to have the 3rd choice be the selected value. Jeff -- Original message -- From: Thomas Guettler <[EMAIL PROTECTED]> > > Am Mittwoch, 1. August 2007 15:58 schrieb jeffhg58: > > In newforms when I use the choicefield, I haven't been able to figure > > out how to set the value to say the third value in the drop down list. > > I tried setting the initial=3 but that did not seem to work. > > > > Here is the definition of the choicefield > > > > status = forms.ChoiceField(required=False, choices=statlist) > > Hi, > > if choices=(("a", "Letter A",) ... > > you set initial to "a". Simple, isn't it? > > Thomas > > > --~--~-~--~~~---~--~~ 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: schema evolution
added postgres unit tests to the schema-evolution branch. also fixed a bug where constraint lookups in postgres broke after a model rename. thanks, derek --~--~-~--~~~---~--~~ 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: remember me feature
If you want something that lasts longer than a session (for how-ever you configured it on your system), then you might consider writing your own cookie, and checking for it at the relevant places. I don't use this mechanism for authentication, but as a little additional personalization touch to remember who's logged in from that browser previously. It's not super-obvious, but here's a little snippet example of setting the cookie: my_response.set_cookie(key=USER_PERSISTENCE_NAME, value=username, max_age=None, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN ) and getting rid of it: my_response.delete_cookie(USER_PERSISTENCE_NAME) and to read it, we added a little to a central Context Processor to make the data available in all the templates: ctx['saved_username'] = request.COOKIES.get(USER_PERSISTENCE_NAME, "") On 8/1/07, JHeasly <[EMAIL PROTECTED]> wrote: > > Hey James, > > This might get you going in the right direction: > > "The default SessionMiddleware that comes with Django lets you pick if > you want all sessions to be browser-length or persistent, if you want > to use different types of sessions based on a users preference (e.g. > the good old "Remember Me" check-box) you're gonna have to write your > own middleware. ... " > > http://code.djangoproject.com/wiki/CookBookDualSessionMiddleware > > Hope this helps. > > John > > > > > --~--~-~--~~~---~--~~ 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: How can I re-use the filtering and sorting from the admin pages in my view?
Ben, Vince, Thanks for the input! It confirms what I suspected after a brief scan through the admin doc and the code. Johan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Distinct rows by a column field?
I have a log that I want to generate reports from. It is an access log where each row represents a "hit." One of the columns in the table is a key and each user has a unique key. Is there a way using Django's database API to get the count of distinct keys so I can get the number of unique users? Right now I have in my model... def get_distinct_keys(self): from django.db import connection cursor = connection.cursor() cursor.execute("SELECT DISTINCT key FROM log_accesslog") rows = cursor.fetchall() return rows ...which works fine. It seems that the Django distinct method does not accept a column argument (why?)? Is there a cleaner way to do this? Thanks, Ryan --~--~-~--~~~---~--~~ 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: remember me feature
Hey James, This might get you going in the right direction: "The default SessionMiddleware that comes with Django lets you pick if you want all sessions to be browser-length or persistent, if you want to use different types of sessions based on a users preference (e.g. the good old "Remember Me" check-box) you're gonna have to write your own middleware. ... " http://code.djangoproject.com/wiki/CookBookDualSessionMiddleware Hope this helps. John --~--~-~--~~~---~--~~ 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: Can a ManyToManyField only shows certain records in an admin using edit_inline?
We'll I kinda got it to work. I added the following (limit_choice_to): sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': 2}) /// That works fine. However, I obviously want to take out the '2'. I tried the following but it does not seem to work: sandp = models.ManyToManyField(Choice, limit_choices_to = {'choice': collection.id}) I guess I need to know how do I get the id for the current collection that I'm adding the style to? Thanks On Aug 1, 2:17 am, Will McCutchen <[EMAIL PROTECTED]> wrote: > > Is there anyway that I can have the 'sandp' Field only > > show choices that are tied to that collection? > > Try using the limit_choices_to argument to > ManyToManyField:http://www.djangoproject.com/documentation/model-api/#many-to-many-re... > > Hope this helps, > > Will. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Apache + mod_python (noob django/python/apache) import error in website url file
Hi all, I need a bit of help. I figure that I am probably doing something stupid, but here goes. I am trying to start a website and I have Apache cofigured to use mod_python. I have a location node in my httpd.conf set up as follows (the rest of the file is currently taking the defaults for Apache): SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE settings PythonInterpreter my_django PythonDebug On PythonPath "['/home/shawn/myCode/intertubewaypoint/'] + sys.path" SetHandler None SetHandler None When I navigate to http://intertubewaypoint.com/admin I get an import error (site is still up if you want to hit and diagnose, I will take it down later today whilst I fix it). I can view and use my admin site from the development server when I am developing locally, just can't get to it from outside through Apache. Anyone see what I am doing 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: Problem with __setattr__ and __getattribute__
Hi Dave -- I'm not sure what's going on in your code example, but there's a *much* easier way of copying an object:: >>> o = MyModel.objects.get(pk=1) >>> o.id = None >>> o.save() By setting the ID (or whatever your primary key is called) to ``None`` and calling save() you'll force Django to insert a new object instead of updating the existing one. All that monkeying with ``__dict__`` isn't really needed. /me makes note to think about adding an ``obj.copy()`` method... Jacob --~--~-~--~~~---~--~~ 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: loading fixtures: no error, no data
I am using postgresql with postgresql_psycopg2. On 1 Ağustos, 17:21, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > > > > Shouldn't Django be reporting that failure? Success messages are > > confusing. > > I _did_ get an error message, warning me about an invalid primary key: > > psycopg.DatabaseError: {: 'ERROR: insert > or update on table "mytest_documentissue" violates foreign key > constraint "mytest_documentissue_user_id_fkey"\nDETAIL: Key > (user_id)=(2) is not present in table "auth_user".\n'} > > Admittedly, the error was a little cryptic, but it did name the model > and pk value that was missing. > > I can only presume this is a database-specific difference. I'm using > Postgres - what database backend are you using? > > 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-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: loading fixtures: no error, no data
On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > Shouldn't Django be reporting that failure? Success messages are > confusing. I _did_ get an error message, warning me about an invalid primary key: psycopg.DatabaseError: {: 'ERROR: insert or update on table "mytest_documentissue" violates foreign key constraint "mytest_documentissue_user_id_fkey"\nDETAIL: Key (user_id)=(2) is not present in table "auth_user".\n'} Admittedly, the error was a little cryptic, but it did name the model and pk value that was missing. I can only presume this is a database-specific difference. I'm using Postgres - what database backend are you using? 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-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: loading fixtures: no error, no data
Yes, the problem was I didn't have the second user on the db that I an trying to initialize. As I only dump data for one application, and the user data is in an other application, the foreign key constraint fails. Thanks a lot... Shouldn't Django be reporting that failure? Success messages are confusing. On 1 Ağustos, 16:57, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > > > > My bad. In my previous post, I think it would be a good idea to crop > > the models a bit for simplicity. Please use this one: > >http://dpaste.com/hold/15751/ > > Works fine for me, as long as you have two users defined (pk=1 and > pk=2). The fixture you provided didn't define them, but I presume you > have created them elsewhere. > > Whatever the problem is, it's very much local to your machine. I can > only suggest starting a clean project from scratch (paying particular > attention to paths, settings, etc), and see if you can replicate the > issue. > > 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-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: How to get selected value set in newforms
Am Mittwoch, 1. August 2007 15:58 schrieb jeffhg58: > In newforms when I use the choicefield, I haven't been able to figure > out how to set the value to say the third value in the drop down list. > I tried setting the initial=3 but that did not seem to work. > > Here is the definition of the choicefield > > status = forms.ChoiceField(required=False, choices=statlist) Hi, if choices=(("a", "Letter A",) ... you set initial to "a". Simple, isn't it? Thomas --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
OT: Adrian's mug on OSCON site
Browsing the lineup of speakers at OSCON, I noticed a familar face in the top banner, front & center: http://conferences.oreillynet.com/pub/w/58/presentations.html How's it feel to be the poster-child for OSCON? ;) -tkc --~--~-~--~~~---~--~~ 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 get selected value set in newforms
In newforms when I use the choicefield, I haven't been able to figure out how to set the value to say the third value in the drop down list. I tried setting the initial=3 but that did not seem to work. Here is the definition of the choicefield status = forms.ChoiceField(required=False, choices=statlist) Thanks, Jeff --~--~-~--~~~---~--~~ 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: loading fixtures: no error, no data
On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > My bad. In my previous post, I think it would be a good idea to crop > the models a bit for simplicity. Please use this one: > http://dpaste.com/hold/15751/ Works fine for me, as long as you have two users defined (pk=1 and pk=2). The fixture you provided didn't define them, but I presume you have created them elsewhere. Whatever the problem is, it's very much local to your machine. I can only suggest starting a clean project from scratch (paying particular attention to paths, settings, etc), and see if you can replicate the issue. 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-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: website template compatible with django
> There are professional-looking website templates for sale in several > places (templatemonster, etc). > Can those be used easily with Django ? > Do they need to be designed specifically for Django ? Django's templates are considerably more friendly towards such uses than many templating languages are (a coworker was recently lamenting the annoyances of doing ASP templates that don't play well in HTML WYSIWTF[*] editors). Django's templates are pretty much raw HTML with a few extra pseudo-tags (in curly-braces) for presentation logic. Thus, you should be able to use pretty much any HTML template you want and then just insert the django tags to adjust them as desired. This assumes a small modicum of competency in HTML to know where to make those changes, but it should be pretty easy. -tim ([*] I love this...from a recent UserFriendly.org cartoon) --~--~-~--~~~---~--~~ 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: loading fixtures: no error, no data
My bad. In my previous post, I think it would be a good idea to crop the models a bit for simplicity. Please use this one: http://dpaste.com/hold/15751/ On 1 Ağustos, 16:31, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > > Thanks for the reply Russ... > > > The models are here: > >http://dpaste.com/hold/15746/ > > > The dump in json format is here: > >http://dpaste.com/hold/15747/ > > Are you sure the fixture comes from these models? I get an immediate > failure because industry doesn't have a field named slug - the fixture > references this field, but the model doesn't. > > 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-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: UnicodeEncodeError
Am Mittwoch, 1. August 2007 04:23 schrieb Alexandre Forget: > Hi, > > I am stuck with this error, does someone know what it mean? > I am using django svn and sqlite. > > This error happen when I try to delete an object with the admin > interface but it delete fine with the shell. > Hi, I submitted a small patch to views/debug.py to show the characters before and after the wrong charachter. This helps you to find the place where the string comes from: http://code.djangoproject.com/attachment/ticket/5046/views_debug_unicodeerror_hint.diff Since my python code is in latin1 I get this message often. Be sure to use only unicode strings in your code: example: models.py ... foo=models.CharField(maxlength=6, choices=( ("umlaut", u"üöäßÜÖÄ"), Thomas --~--~-~--~~~---~--~~ 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: loading fixtures: no error, no data
On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > Thanks for the reply Russ... > > The models are here: > http://dpaste.com/hold/15746/ > > The dump in json format is here: > http://dpaste.com/hold/15747/ > Are you sure the fixture comes from these models? I get an immediate failure because industry doesn't have a field named slug - the fixture references this field, but the model doesn't. 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-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: loading fixtures: no error, no data
I have custom save methods like: class Issue(models.Model): title = models.CharField(maxlength=150) parent = models.ForeignKey('self', null = True, blank = True) industries = models.ManyToManyField(Industry, null = True, blank = True) slug = models.SlugField(maxlength = 100, editable = False) def save(self): slug = self.title parent = self.parent while parent: slug = '%s %s' % (parent, slug) parent = parent.parent self.slug = slugify(slug) super(Issue, self).save() for child in Issue.objects.filter(parent = self): child.save() Using the admin, I was able to add objects, so I think the custom save() works fine. Can loaddata be misinterpreting the custom save()? For the paths suggestion, I drop the tables and run syncdb. The tables are created, but they are not populated. Syncdb sees correctly which db I meant while creating tables. In my previous post, I have omitted custom save() methods in the models for simplicity but I see it can be critical, so here is the full model: http://dpaste.com/hold/15751/ On 1 Ağustos, 16:14, omat <[EMAIL PROTECTED]> wrote: > Thanks for the reply Russ... > > The models are here:http://dpaste.com/hold/15746/ > > The dump in json format is here:http://dpaste.com/hold/15747/ > > On 1 Ağustos, 15:52, "Russell Keith-Magee" <[EMAIL PROTECTED]> > wrote: > > > On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > > > Installed 34 object(s) from 1 fixture(s) > > > If this message is getting printed, then the fixture is getting loaded > > _somewhere_, save() has been called on 34 object instances, and the > > transaction has been successfully committed. > > > The only way I can think that the data would go missing was if it was > > loaded into a different database. However, I can't think of any > > obvious way that you could do this. > > > Another possibility is that the loaddata success is getting > > misreported somehow. If you forward your model and fixture I'll try it > > at my end and see if I can replicate the problem. > > > 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-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: loading fixtures: no error, no data
On 8/1/07, David Reynolds <[EMAIL PROTECTED]> wrote: > > How about .save() is being overridden and Super(Model, self).save() > isn't being called? FYI - as of [5658], fixtures call save() directly on the base Model class, ignoring any user-defined save method. 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-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: view and urls..
Hi, try tu use a string for the view path. --~--~-~--~~~---~--~~ 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: loading fixtures: no error, no data
Thanks for the reply Russ... The models are here: http://dpaste.com/hold/15746/ The dump in json format is here: http://dpaste.com/hold/15747/ On 1 Ağustos, 15:52, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > > > > Installed 34 object(s) from 1 fixture(s) > > If this message is getting printed, then the fixture is getting loaded > _somewhere_, save() has been called on 34 object instances, and the > transaction has been successfully committed. > > The only way I can think that the data would go missing was if it was > loaded into a different database. However, I can't think of any > obvious way that you could do this. > > Another possibility is that the loaddata success is getting > misreported somehow. If you forward your model and fixture I'll try it > at my end and see if I can replicate the problem. > > 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-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 -~--~~~~--~~--~--~---
view and urls..
I doesnt undestand where is the problem in this code : The Application is : Cit2 !--> Utente I need to call the view Login in Utente so in the url i say : from django.conf.urls.defaults import * urlpatterns = patterns('', # Example: (r'^/?$', login), # Uncomment this for admin: # (r'^admin/', include('django.contrib.admin.urls')), ) I tried whit cit2.utente.view.login and other .. but Doesnt work.. Login view is : # Create your views here. from cit2 import views def login: html = "HI" return HttpResponse(html) Now whit : login .. say NameError at / name 'login' is not defined Request Method: GET Request URL: http://127.0.0.1:8000/ Exception Type: NameError Exception Value: name 'login' is not defined Exception Location: /home/tulap/cit2/../cit2/urls.py in , line 6 Python Executable: /usr/bin/python Python Version: 2.5.1 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: loading fixtures: no error, no data
On 1 Aug 2007, at 1:52 pm, Russell Keith-Magee wrote: On 8/1/07, omat <[EMAIL PROTECTED]> wrote: Installed 34 object(s) from 1 fixture(s) If this message is getting printed, then the fixture is getting loaded _somewhere_, save() has been called on 34 object instances, and the transaction has been successfully committed. The only way I can think that the data would go missing was if it was loaded into a different database. However, I can't think of any obvious way that you could do this. Another possibility is that the loaddata success is getting misreported somehow. If you forward your model and fixture I'll try it at my end and see if I can replicate the problem. How about .save() is being overridden and Super(Model, self).save() isn't being called? Check you don't have 2 folders/projects of the same name on your python path and it's using the database referred to in the other one's settings file? Thanks, Dave -- David Reynolds [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
Re: loading fixtures: no error, no data
On 8/1/07, omat <[EMAIL PROTECTED]> wrote: > > Installed 34 object(s) from 1 fixture(s) If this message is getting printed, then the fixture is getting loaded _somewhere_, save() has been called on 34 object instances, and the transaction has been successfully committed. The only way I can think that the data would go missing was if it was loaded into a different database. However, I can't think of any obvious way that you could do this. Another possibility is that the loaddata success is getting misreported somehow. If you forward your model and fixture I'll try it at my end and see if I can replicate the problem. 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-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: website template compatible with django
--~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
loading fixtures: no error, no data
Hi, It seems easy as 1-2-3 but, I couldn't manage to loaddata in my fixture back into the db. Despite the success message at the end, no data is inserted into the db. I am running django revision 5783 with postgres. I tried the following for json and xml. Both end with success messages but with no data inserted. > python manage.py dumpdata main > main/fixtures/initial_data.json the fixture file is created. then I clear the database and run: > python manage.py syncdb and get: Loading 'initial_data' fixtures... Installing json fixture 'initial_data' from 'D:\django\gd\main \fixtures'. Installed 34 object(s) from 1 fixture(s) But despite this success message, no data is inserted into the database. Any ideas? I may post my app's models and the fixture file, if needed. Thanks, oMat --~--~-~--~~~---~--~~ 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: understanding request.user
Am Mittwoch, 1. August 2007 10:23 schrieb james_027: > hi, > > I am seeking some enlightenment as why the user (variable use to track > if the user is logged in or not) seems to be on the request level and > not on the session which is the practice of most or all of web > framework? If I am not wrong request.user is done on the middleware > which will get executed on every request, this could be a unnecessary > process? request.user gets created by to OR mapping (from the sql database). request.session comes from a pickle (serialized to a bytestream). Both needs to be done for every request. You could use caching, but object caching (like for request.user) is not possible up to now. Thomas --~--~-~--~~~---~--~~ 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: Postgresql and transactions, revisited
Russell Keith-Magee scribit: > On 7/31/07, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > >> I had the problem that any db error in any of my tests (including >> setups) would cause all following tests to fail (because the transaction >> was not rolled back). This was made even worse by the fact that I used >> the db in tearDown, which did not work very well either (I have since >> started using django.test.TestCase, so I don't use tearDown much). >> > > I can see how this problem could arise. The test framework doesn't > have any special handling for errors, so if one test pushes the > database into an error state, subsequent tests may fail. > > Ideally, test cases should be completely independent. It would be much > nicer to have a single test fail with a clean error than have one test > fail due to an error, and then all subsequent tests failing as a > consequence of the first failure. > > >> I think the problem at the base of all this is that postgresql's >> transaction/error handling semantics are different from that of the >> other backends - while Django treats it as if it was the same. I would >> like to take a stab at fixing this (at the appropriate level, which I am >> not too sure I have identified). But before I do that, I would like to >> hear if anyone has any reasons why this should not be done ... >> > > I doubt this is a postgres-specific problem. The exact exception that > is thrown will be postgres specific, but all backends will throw > exceptions, and will require transaction rollback (or some other > handling) to allow the test suite to continue. > As far as I can tell, mySQL does not invalidate the current transaction when it encounters an error. Thus you can do """ mysql> create table foo (bar varchar(20) primary key) engine innodb; Query OK, 0 rows affected (0.28 sec) mysql> begin; Query OK, 0 rows affected (0.00 sec) mysql> insert into foo values ('foo'); Query OK, 1 row affected (0.19 sec) mysql> insert into foo values ('foo'); ERROR 1062 (23000): Duplicate entry 'foo' for key 1 mysql> insert into foo values ('bar'); Query OK, 1 row affected (0.00 sec) """ While in postgres you get: """ spider=> create table foo (bar varchar(20) primary key) ; NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo" CREATE TABLE spider=> begin; BEGIN spider=> insert into foo values ('foo'); INSERT 0 1 spider=> insert into foo values ('foo'); ERROR: duplicate key violates unique constraint "foo_pkey" spider=> insert into foo values ('bar'); ERROR: current transaction is aborted, commands ignored until end of transaction block """ For the record, I think mySQL is the one making sense here. sqlite behave the same way. I don't have an Oracle installation to test on (nor do I ever wish to get one). > This does raise the larger issue of generic error handling for the > database backends; It has been suggested that the various backend > exceptions should be wrapped by a generic Django database failure > exception. If database exceptions were normalized in this way, > catching the type of errors you describe would become much cleaner - > both in tests, and in the general case. > This sounds very much along the lines that I have been looking at for solving the issue. Out of interest, which versions of postgres are we supporting? I am asking because I think the mySQL behavior can only be mimicked using savepoints, which became available in 8.0. I see that there are in fact no mention of version numbers of any of the db products on the installation page. IMO, this should be fixed as well. I guess I should log an issue ... >> I will post some test cases with suggested behavior later (in a ticket). >> If someone could give me a clue to how I can easily run the django test >> suite, I would be glad. >> > > Most certainly log this issue; test cases are most welcome; fixes even > more welcome. > > I suspect the best approach will be to extend the django TestCase, > overriding one of the test run methods to provide transaction > checking. It may be helpful to define this behaviour as a decorator; > this would also allow users with tests based on unittest.TestCase, > rather than django.test.TestCase. > Thanks for the comments. I will log two issues: 1. Different backends have differen transaction semantics (and one of them makes error handling distinctly hard to use, ie pg). 2. Testcases give problems because of this. I am separating them since the second one is relatively easier to fix.. Nis --~--~-~--~~~---~--~~ 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: email_message documentation
Thanks Kpoh There's a misleading piecve of documentation in there about EmailMultiAlternatives I've reported a ticket to trac to fix it. http://code.djangoproject.com/ticket/5042#preview On Aug 1, 10:43 am, KpoH <[EMAIL PROTECTED]> wrote: > check this outhttp://www.djangoproject.com/documentation/email/ > > Matt Davies пишет: > > > Hello everyone > > > I've been testing using the send_mail function, but I've heard that > > it's now deprecated, is that right? > > > I've searched for some documentation on how to use the new > > Email_Message function but can't find any. > > > Can someone send me some links please? > > > humbly yours > > -- > Artiom Diomin, Development Dep, "Comunicatii Libere" > S.R.L.http://www.asterisksupport.ruhttp://www.asterisk-support.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-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: email_message documentation
check this out http://www.djangoproject.com/documentation/email/ Matt Davies пишет: > Hello everyone > > I've been testing using the send_mail function, but I've heard that > it's now deprecated, is that right? > > I've searched for some documentation on how to use the new > Email_Message function but can't find any. > > Can someone send me some links please? > > humbly yours -- Artiom Diomin, Development Dep, "Comunicatii Libere" S.R.L. http://www.asterisksupport.ru http://www.asterisk-support.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-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 __setattr__ and __getattribute__
Hello. I have a view that should duplicate a model object and save it in the database. I tried with this code: obj = MyModel.objects.get(pk=1) obj2 = MyModel() for e in obj.__dict__: if e != 'id': obj2.__setattr__(e, obj.__getattribute__(e)) #error obj2.save() But I get this error: Exception Type: TypeError Exception Value:expected 2 arguments, got 1 in the line marked with #error... The same code works if I execute it from the django shell... Why? By the way, is this a good way to duplicate an object or there are better methods? 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 -~--~~~~--~~--~--~---
email_message documentation
Hello everyone I've been testing using the send_mail function, but I've heard that it's now deprecated, is that right? I've searched for some documentation on how to use the new Email_Message function but can't find any. Can someone send me some links please? humbly yours --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Trouble with installing stockphoto
I am having a bit of trouble installing stockphoto ( http://www.carcosa.net/jason/software/django/stockphoto/README.html ) I am wanting to try out just the functionality of the app itself, not yet integrating it with a current project and am running into a few errors. Here is my work flow as to how I've set up a new project to have stockphoto: I downloaded the stockphoto-0.2.tar.gz, uncompressed it and have the folder stockphoto-0.2 in c:/django/stockphoto-0.2 command line >cd : c\django c\django> manage.py startproject testproject from here, I have tried multiple ways to install stockphoto as an app inside the c:/django/testproject/ directory and i just can't get it. Any and all help you can give this newbie will be extremely appreciative. Thank you guys! Rocksteady, Danno~ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
understanding request.user
hi, I am seeking some enlightenment as why the user (variable use to track if the user is logged in or not) seems to be on the request level and not on the session which is the practice of most or all of web framework? If I am not wrong request.user is done on the middleware which will get executed on every request, this could be a unnecessary process? Thanks james --~--~-~--~~~---~--~~ 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: User model (unique email)
Patrick Anderson napisał(a): > I'd like to create a couple of views that would allow users to retrieve > their forgotten username or password by email. > > It seems to me that the only reliable way to do this would be for my > application to require unique email addresses for User objects. However > email field in django.contrib.auth.models.User is optional. > > I'd prefer not to hack the contrib.auth application and change User > model, so perhaps that constraint should be included in my application > code, but I'm not sure what the best way to do it should be. > > Any clues? As a last resort, you can monkeypatch your database and add unique constraint to the auth_user.email column. We did that and in our case this requires only one additional check when adding user. -- Jarek Zgoda Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) --~--~-~--~~~---~--~~ 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: Can a ManyToManyField only shows certain records in an admin using edit_inline?
> Is there anyway that I can have the 'sandp' Field only > show choices that are tied to that collection? Try using the limit_choices_to argument to ManyToManyField: http://www.djangoproject.com/documentation/model-api/#many-to-many-relationships Hope this helps, Will. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
website template compatible with django
Hi all, I am a total Django newbie. Hence the probably silly questions: There are professional-looking website templates for sale in several places (templatemonster, etc). Can those be used easily with Django ? Do they need to be designed specifically for Django ? Do you know of any vendor that does it ? If not, what to look for in a template order to make sure it will be relatively easy to use with Django ? 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-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 -~--~~~~--~~--~--~---
Silly Shiny Flash on Django
I just started porting SonomaSunshine to Django, LOL!!! Here is the first Hey Ya'll (aka Hello World) page... Uses the MXMLC compiler and Django to create and edit the SWF. The Django version is going to integrate Papervision3D stuff into SonomaSunshine... http://samfeltus.com/django/hey_yall.html Sam the Gardener Live From LA The old TurboGears generated pages... http://samfeltus.com/site_index.html --~--~-~--~~~---~--~~ 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: ANN: django-lifestream
really good, 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 -~--~~~~--~~--~--~---