Re: how to display an image inside Django
Hi, Thanks for ur reply. I was asking about the ImageField. tried out the tutorials, but its not working out. Where all(views,models,urls.py,settings.py) should we make editings inorder to work. Please help me On Tue, May 11, 2010 at 6:49 PM, Jason Leveillewrote: > On May 11, 7:10 am, ravi krishna wrote: > > Hi, > > I am a beginner in Django . > > Can somebody tel me how to display an image in django... > > if anyone has the right tutorial for beginners, please share with me.. > > -- > > Regards, > > Rav! > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > Are you uploading the image with ImageField? If so, the ImageField > attribute in your model will have image related data that you will be > able to access in a template: > http://docs.djangoproject.com/en/dev/topics/files/#topics-files. > > Also, you can always just insert an image directly in your template. > Something like: > > If you are really green and just need a place to get started, I would > recommend the intro tutorial: > http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Regards, Rav! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New User Stuck on Tutorial Part 2
Thanks, Mike... I've got some studying to do! :) On 05/10/2010 11:47 PM, Mike Dewhirst wrote: On 11/05/2010 4:04pm, Mike Dewhirst wrote: On 11/05/2010 3:42pm, Old Davy wrote: On 05/10/2010 08:18 PM, Shawn Milochik wrote: Exactly what directory is your copied template in? It's most likely not in the right place. Ensure that you have a template dir that your settings knows about, and that template dir has a subdirectory called 'admin' where that file is placed. Shawn That would make the most sense, and that would be my working assumption. But I can't for the life of me see where the disconnect is. this is the string that's in the TEMPLATE_DIRS section of my settings.py file: "/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS This is mine ... # if templates are not found here look in app_name/templates TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),) This puts my templates directory in the same dir as my settings.py file. Inside it I have a sub-dir for each application for which I want templates. For example, in one of them I have ... ../templates/admin/base_site.html Which contains ... {% extends "base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %} {% block branding %} {% trans 'Mysite administration' %} {% endblock %} ... and which turns Django Admin into Mysite admin. However, the "base.html" which it extends is actually in ../templates If I wanted Mysite base_site.html to extend the real Django base.html I would have to put ... {% extends "admin/base.html" %} Just realised I could have confused you a little. So You can extend anything you want to specifically nominate but if you just nominate a bare filename the way I do with base.html in ... mysite/templates/admin/base_site.html ... base.html has to exist in TEMPLATE_DIRS (mysite/templates) If you want to extend "admin/base.html" from the above base_site.html then Django looks first in ... TEMPLATES_DIR/admin ... and if it doesn't find it then it looks in site-packages/django/contrib/admin/templates/admin Mike HTH Mike That's exactly the path that my directories show, including my idiosyncratic upper case letters. I did find the file that my poll app is referencing. Turns out it was in my '/usr/local/lib/python2.6... path instead of my home directory. So when I modified THAT file, it used my changes. However, that still doesn't help, as it's not using the file that I copied to my local directory. I suppose I can play with a few more directories and see what happens... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updating profiles
I figured this out - it was a silly error caused by the ordering of my URLconf for the profile app. URL I was using was triggering a different view. Thanks Bill and CrabbyPete for having a look. Appreciated! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multiple django version on developer machine
On 2010-05-11, at 7:26 PM, james_027 wrote: > While I have a number of django apps develop for Django 1.1 ... I also > want to use Django 1.2 for my new project. How can I have multiple > version of Django in my machine where my apps will be instructed > either to use 1.1 or 1.2 You should look at using virtualenv to isolate your environment: http://pypi.python.org/pypi/virtualenv -- Andy McKay, @andymckay Django Consulting, Training and Support -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Multiple django version on developer machine
Hi all, While I have a number of django apps develop for Django 1.1 ... I also want to use Django 1.2 for my new project. How can I have multiple version of Django in my machine where my apps will be instructed either to use 1.1 or 1.2 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updating profiles
Bill, I use that setting and I have tried different variations and the result is the same(error is still there): myproject.Profile myproject.profiles profiles.Profile On May 11, 7:29 pm, CrabbyPetewrote: > should be > > AUTH_PROFILE_MODULE = 'app_name.Profile' > > On May 11, 10:15 am, Bill Freeman wrote: > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django form inline validation
Hi All, I am a newbie in Django. I am currently working on a user registration form. I am trying to integrate a Jquery inline validation script in my django code which is not a success. What I would like to have is use something of this sort http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ in my django form with the query for username. What all files am I suppose to edit except the template. Can you all django lovers please help me find a way to get this. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Practical Django Projects 2: Weblog urls.py help...
> I think the problem is due to the month digit... The book opted to use > the 3-letter month name vs the two digits... I personally like the > month as digits so I changed the urls.py and models.py to use %m. My coworker solved this problem for me: entry_info_dict = { 'queryset': Entry.objects.all(), 'date_field': 'pub_date', 'month_format': '%m', } I needed to pass "month_format" as %m to django.views.generic.date_based... From what the docs say, the date_based generic view defaults to %b. So simple of a fix! Thanks! M -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updating profiles
Yep. Probably should have been called AUTH_PROFILE_CLASS. On Tue, May 11, 2010 at 7:29 PM, CrabbyPetewrote: > should be > > AUTH_PROFILE_MODULE = 'app_name.Profile' > > On May 11, 10:15 am, Bill Freeman wrote: >> Is AUTH_PROFILE_MODULE set correctly in settings.py? >> >> >> >> On Tue, May 11, 2010 at 6:43 AM, django_jedi wrote: >> > OK, I'm baffled. I must be missing something right in front of my >> > face... >> >> > I'm trying to create a form that will allow users to update their >> > profiles. No matter what I try, I get a >> >> > "User matching query does not exist." >> >> > ...error. Below is the associated view, and the related model and >> > form clases. Any help would be appreciated. >> >> > VIEW >> > --- >> > @login_required >> > def update_profile(request): >> > try: >> > myprofile = request.user.get_profile() >> > except: >> > up = Profile(user=request.user) >> > up.save() >> > myprofile = request.user.get_profile() >> >> > if request.method == 'POST': >> > form = ProfileUpdateForm(request.POST, request.FILES, >> > instance=myprofile) >> > if form.is_valid(): >> > form.save() >> > else: >> > form = ProfileUpdateForm(instance=myprofile) >> >> > return render_to_response('profiles/update.html', {'form':form, >> > 'profile':myprofile}, >> > context_instance = RequestContext(request)) >> >> > MODEL >> > --- >> > class Profile(models.Model): >> > # This is the only required field >> > user = models.ForeignKey(User, unique=True) >> > picture = models.ImageField(upload_to='img/profilepics/%Y%m%d/', >> > blank=True, null=True) >> > # The rest is completely up to you... >> > favorite_band = models.CharField(max_length=100, blank=True) >> > favorite_cheese = models.CharField(max_length=100, blank=True) >> > lucky_number = models.IntegerField(null=True, blank=True) >> >> > FORM >> > --- >> > class ProfileUpdateForm(ModelForm): >> > class Meta: >> > model = Profile >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group >> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updating profiles
should be AUTH_PROFILE_MODULE = 'app_name.Profile' On May 11, 10:15 am, Bill Freemanwrote: > Is AUTH_PROFILE_MODULE set correctly in settings.py? > > > > On Tue, May 11, 2010 at 6:43 AM, django_jedi wrote: > > OK, I'm baffled. I must be missing something right in front of my > > face... > > > I'm trying to create a form that will allow users to update their > > profiles. No matter what I try, I get a > > > "User matching query does not exist." > > > ...error. Below is the associated view, and the related model and > > form clases. Any help would be appreciated. > > > VIEW > > --- > > @login_required > > def update_profile(request): > > try: > > myprofile = request.user.get_profile() > > except: > > up = Profile(user=request.user) > > up.save() > > myprofile = request.user.get_profile() > > > if request.method == 'POST': > > form = ProfileUpdateForm(request.POST, request.FILES, > > instance=myprofile) > > if form.is_valid(): > > form.save() > > else: > > form = ProfileUpdateForm(instance=myprofile) > > > return render_to_response('profiles/update.html', {'form':form, > > 'profile':myprofile}, > > context_instance = RequestContext(request)) > > > MODEL > > --- > > class Profile(models.Model): > > # This is the only required field > > user = models.ForeignKey(User, unique=True) > > picture = models.ImageField(upload_to='img/profilepics/%Y%m%d/', > > blank=True, null=True) > > # The rest is completely up to you... > > favorite_band = models.CharField(max_length=100, blank=True) > > favorite_cheese = models.CharField(max_length=100, blank=True) > > lucky_number = models.IntegerField(null=True, blank=True) > > > FORM > > --- > > class ProfileUpdateForm(ModelForm): > > class Meta: > > model = Profile > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Weird inconsistencies for same queryset in different Django instances
On Tue, May 11, 2010 at 8:27 PM, Daniel Rosemanwrote: > On May 11, 7:08 pm, Malcolm Box wrote: > > Hi, > > > > I've run into a weird bug that has me scratching my head - I'm seeing > > inconsistent results from a queryset between various apache processes and > > the django shell. I.e. sometimes a GET gives me the right response (as > it > > hits a "correct" Apache instance) and other times it gives a wrong > > response. Restarting Apache causes problem to go away, but it resurfaces > > later. > > > > I have a Poll class which has a start_time and an end_time, both of which > > are optional, plus an enabled field. A poll is considered active if it's > > enabled, and if it has a start_time then now > start_time, and if it has > an > > end_time then now < end_time. > > > > What I'm seeing is that sometimes polls with a start_time that is before > now > > are not showing up in the responses when I do a series of GETs. So e.g. > > first GET - shows poll, second one - doesn't show, third - doesn't, > fourth - > > does and so on. > > > > From a fresh python shell, the Poll.objects.active() call always gives > the > > right results. > > > > The code in question is: > > > > class PollManager(models.Manager): > > def active(self): > > qs = super(PollManager, > self).get_query_set().filter(enabled=True) > > q_start = Q(start_time__isnull=True) | > > Q(start_time__lte=datetime.datetime.now()) > > q_end = Q(end_time__isnull=True) | > > Q(end_time__gte=datetime.datetime.now()) > > return qs.filter(q_start,q_end) > > > > Where the models are is: > > > > class Event(models.Model): > >enabled = models.BooleanField() # automatic default false > > other fields > > > > class Poll(models.Model): > > event = models.ForeignKey(Event, db_index=True) > > enabled = models.BooleanField() # automatic default false > > start_time = models.DateTimeField(blank=True, null=True, > help_text="Time > > to enable this poll (optional)") > > end_time = models.DateTimeField(blank=True, null=True, > help_text="Time > > to close this poll (optional)") > > > > objects = PollManager() > > > > The view logic is basically: > > > > def view_polls(request, event_id): > > filtered_set = self.queryset._clone()# Queryset is > > Poll.objects.active().filter(event__enabled = True) > > filtered_set = filtered_set.filter(event__id=event_id) > > return render_to_response(template, filtered_set) > > > > (this has been elided and adapted - original code is using > django-rest-api, > > JSON responder etc. But the call boils down to this) > > > > I'm confused as to what the problem could be - any clues? > > > > Cheers, > > > > Malcolm > > I'd like to see how the queryset is assigned to `self`. My suspicion > would be that the arguments are being preserved across requests - when > it's first instantiated, it correctly uses the current time to filter, > but on subsequent calls it is still using the time as of the first > request. > The queryset is being initialised in the construction of a callable which is then used for the view. So yes, it probably is only being initialised once on server startup. Thank you! Still testing the fix, but I think this will fix it. Cheers, Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Hi guys, compatibility issues between django 1.1.1, satchmo 0.9 and postgresql 8.4?
Rafael, You should probably direct your question to the satchmo-user's list to get more responses. I'm not aware of any Postgresql specific issues so if you can provide more details on the satchmo list, we'll try to help. -Chris On Tue, May 11, 2010 at 5:35 PM, Rafael Pinedawrote: > Hi guys, im new here but recently i came across this problem of a > little project of mine, who runs great in sqlite3 but when i try to go > into production mode (using postgresql 8.4), it just doesnt let me > syncdb, so i was wondering if anyone knew about incompatibilities and > such. > > > > Rafael Pineda > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hi guys, compatibility issues between django 1.1.1, satchmo 0.9 and postgresql 8.4?
Hi guys, im new here but recently i came across this problem of a little project of mine, who runs great in sqlite3 but when i try to go into production mode (using postgresql 8.4), it just doesnt let me syncdb, so i was wondering if anyone knew about incompatibilities and such. Rafael Pineda -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
surveys
I have a project that I'm working on that works like this: the user enters some points on a map which are then stored in a database as a LineString object (via geodjango). Along with the geographic data, the user is given a survey to fill out consisting of simple questions like "how fun was this", "how old are you", and "was the parking sufficient", etc. There will be a pool of roughly 100 questions, and the survey will be constructed based on the locale of the user. Different locales results in different sets of questions. There are 40-50 locales for this project. My question is how should I set up the surveys. I don't really want to hard code each survey per locale. I'd prefer to have the questions and choices defined in the database. There is a reusable app called "django-survey" but as far as I can tell the project is completely undocumented. I have it installed, but I can't figure out how to use it. Is this app the kind of thing that I can use, or is it meant for something else completely? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: choices based on existing entries
On Tue, May 11, 2010 at 4:11 PM, Preston Holmeswrote: > Now I can think of several ways to do this in a form field init, but > it seems like there should be a more reusable way to do it with a > custom field type or mixin by overriding get_choices on the field > object. There is an easy way -- a foreign key. -- "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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
choices based on existing entries
Filemaker has a pattern where you can set the choices of a field to be the indexed contents of that field. Along with an "Other..." choice option to add a new value. This is a very handy way of having user modified choices for a given field. Now I can think of several ways to do this in a form field init, but it seems like there should be a more reusable way to do it with a custom field type or mixin by overriding get_choices on the field object. Has anyone done something like this? -Preston -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Odd error on trunk
I have a project that works OK using v1.1.1. However, if I try to run it on trunk, I get this error: "Error: cannot import name DateField". Just that, no traceback, etc. I have no reference to "DateField" in my project. There was 1 in django_extensions, but removing it and even not loading django_extensions doesn't solve the issue. Switching back to 1.1.1 does, however. Settings.py -> http://dpaste.com/hold/193377/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django with MySQL Connector/Python?
Has anyone made Django work with myconnpy? I've checked out http://github.com/rtyler/connector-django-mysql but the author said it's very outdated and not supported. If you've managed to make Django work with myconnpy, please share your experience. Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Weird inconsistencies for same queryset in different Django instances
On May 11, 7:08 pm, Malcolm Boxwrote: > Hi, > > I've run into a weird bug that has me scratching my head - I'm seeing > inconsistent results from a queryset between various apache processes and > the django shell. I.e. sometimes a GET gives me the right response (as it > hits a "correct" Apache instance) and other times it gives a wrong > response. Restarting Apache causes problem to go away, but it resurfaces > later. > > I have a Poll class which has a start_time and an end_time, both of which > are optional, plus an enabled field. A poll is considered active if it's > enabled, and if it has a start_time then now > start_time, and if it has an > end_time then now < end_time. > > What I'm seeing is that sometimes polls with a start_time that is before now > are not showing up in the responses when I do a series of GETs. So e.g. > first GET - shows poll, second one - doesn't show, third - doesn't, fourth - > does and so on. > > From a fresh python shell, the Poll.objects.active() call always gives the > right results. > > The code in question is: > > class PollManager(models.Manager): > def active(self): > qs = super(PollManager, self).get_query_set().filter(enabled=True) > q_start = Q(start_time__isnull=True) | > Q(start_time__lte=datetime.datetime.now()) > q_end = Q(end_time__isnull=True) | > Q(end_time__gte=datetime.datetime.now()) > return qs.filter(q_start,q_end) > > Where the models are is: > > class Event(models.Model): > enabled = models.BooleanField() # automatic default false > other fields > > class Poll(models.Model): > event = models.ForeignKey(Event, db_index=True) > enabled = models.BooleanField() # automatic default false > start_time = models.DateTimeField(blank=True, null=True, help_text="Time > to enable this poll (optional)") > end_time = models.DateTimeField(blank=True, null=True, help_text="Time > to close this poll (optional)") > > objects = PollManager() > > The view logic is basically: > > def view_polls(request, event_id): > filtered_set = self.queryset._clone() # Queryset is > Poll.objects.active().filter(event__enabled = True) > filtered_set = filtered_set.filter(event__id=event_id) > return render_to_response(template, filtered_set) > > (this has been elided and adapted - original code is using django-rest-api, > JSON responder etc. But the call boils down to this) > > I'm confused as to what the problem could be - any clues? > > Cheers, > > Malcolm I'd like to see how the queryset is assigned to `self`. My suspicion would be that the arguments are being preserved across requests - when it's first instantiated, it correctly uses the current time to filter, but on subsequent calls it is still using the time as of the first request. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Close window after download
Does anyone know how to track if a download completed? On May 6, 9:52 pm, CrabbyPetewrote: > I have code that generates a file for download. I want to close the > window after the user selects the download or even redirect them. > > Here is my code: > > response = HttpResponse(cal.as_string(), mimetype='text/calendar') > response['Content-Disposition'] = 'attachment; filename=schedule.ics' > return response > > I can't close the window before the download using > > > > > > because I get an error that the window closed. > > So after the form download the window is hanging in limbo. If anyone > knows > how to close the window I'd appreciate it. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Weird inconsistencies for same queryset in different Django instances
Change your "datetime.now()"s in your manager to "datetime.now"s. The callable version will be called every time, rather than only once at the start of the process. Regards Scott On May 11, 2:08 pm, Malcolm Boxwrote: > Hi, > > I've run into a weird bug that has me scratching my head - I'm seeing > inconsistent results from a queryset between various apache processes and > the django shell. I.e. sometimes a GET gives me the right response (as it > hits a "correct" Apache instance) and other times it gives a wrong > response. Restarting Apache causes problem to go away, but it resurfaces > later. > > I have a Poll class which has a start_time and an end_time, both of which > are optional, plus an enabled field. A poll is considered active if it's > enabled, and if it has a start_time then now > start_time, and if it has an > end_time then now < end_time. > > What I'm seeing is that sometimes polls with a start_time that is before now > are not showing up in the responses when I do a series of GETs. So e.g. > first GET - shows poll, second one - doesn't show, third - doesn't, fourth - > does and so on. > > From a fresh python shell, the Poll.objects.active() call always gives the > right results. > > The code in question is: > > class PollManager(models.Manager): > def active(self): > qs = super(PollManager, self).get_query_set().filter(enabled=True) > q_start = Q(start_time__isnull=True) | > Q(start_time__lte=datetime.datetime.now()) > q_end = Q(end_time__isnull=True) | > Q(end_time__gte=datetime.datetime.now()) > return qs.filter(q_start,q_end) > > Where the models are is: > > class Event(models.Model): > enabled = models.BooleanField() # automatic default false > other fields > > class Poll(models.Model): > event = models.ForeignKey(Event, db_index=True) > enabled = models.BooleanField() # automatic default false > start_time = models.DateTimeField(blank=True, null=True, help_text="Time > to enable this poll (optional)") > end_time = models.DateTimeField(blank=True, null=True, help_text="Time > to close this poll (optional)") > > objects = PollManager() > > The view logic is basically: > > def view_polls(request, event_id): > filtered_set = self.queryset._clone() # Queryset is > Poll.objects.active().filter(event__enabled = True) > filtered_set = filtered_set.filter(event__id=event_id) > return render_to_response(template, filtered_set) > > (this has been elided and adapted - original code is using django-rest-api, > JSON responder etc. But the call boils down to this) > > I'm confused as to what the problem could be - any clues? > > Cheers, > > Malcolm > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Paginating search results
It's all firing well, thanks for the heads up and the help. On May 11, 9:26 am, Nuno Maltezwrote: > Great, Just make sure you don't end up with multiple "page" arguments > on your query string when navigating through the results (click next; > click next again...). > > Nuno > > > > On Tue, May 11, 2010 at 2:41 PM, Nick wrote: > > The POST thing was the result of late night meltdowns and desperation. > > I tend to just try stupid things when i'm working through an issue > > like this, just seeing what the application is capable of doing. I've > > switched it all back to GET. > > > I found the answer around 1 this morning. You are exactly right, I > > needed to capture the query string and place it in the "next" and > > "previous" page links. Here's how I went about doing that, just in > > case someone else runs into this issue: > > > query_string = request.GET.copy() > > > and then in the dict: > > > 'query_string': query_string.urlencode() > > > On May 11, 4:46 am, Nuno Maltez wrote: > >> You need to pass the current search paramters in your query string > >> (?party=D== ) when you create the links to all the > >> pages, and you need to be able to retrieve them from request.GET in > >> order to recreate the object list (reps) when rendering a specific > >> page (any particular reason why are you using POST in the search > >> form?). > > >> hth, > >> Nuno > > >> On Tue, May 11, 2010 at 1:58 AM, Nick wrote: > >> > I'm trying to paginate results from a search with multiple options. > >> > The only problem is, once I hit the next button it clears the query > >> > and I'm left paginating all the objects in the DB. > > >> > Here is my view: > > >> > def filter_search(request): > >> > if request.POST: > >> > reps = Rep.objects.all() > >> > else: > >> > reps = [] > >> > query = request.POST > >> > if 'q' in request.POST: > >> > q = request.POST.get('q', '') > >> > qset = ( > >> > Q(Last_Name__icontains=q) | Q(First_Name__icontains=1) > >> > ) > >> > reps = reps.filter(qset) > >> > else: > >> > q = [] > >> > if len(q): > >> > qlist = q > >> > else: > >> > qlist = [] > >> > if 'party' in request.POST: > >> > party = request.POST.getlist('party') > >> > reps = reps.filter(Party__in=party) > >> > else: > >> > party = [] > >> > if len(party): > >> > plist = party > >> > else: > >> > plist = [] > >> > paginator = Paginator(reps, 15) > >> > results = paginator.count > >> > try: > >> > page = int(request.POST.get('page', '1')) > >> > except: > >> > page = 1 > >> > try: > >> > repList = paginator.page(page) > >> > except (EmptyPage, InvalidPage): > >> > repList = paginator.page(paginator.num_pages) > >> > finalq = request.POST > >> > return render_to_response("Government/search.html", { > >> > 'reps': repList, > >> > 'query': query, > >> > 'plist': plist, > >> > 'qlist': qlist, > >> > 'results': results, > >> > 'finalq': finalq > >> > }) > > >> > Here is my tpl: > > >> > > >> > > >> > Democrat > >> > Republican > >> > > >> > > > >> > {% if query %} > >> > Your search for {% if qlist %} {{ qlist}} {% endif %} > >> > {% if plist %} {% for p in plist %} {% if forloop.first %} Party > >> > ({{ p }}) {% else %} & Party ({{p}}) {% endif %} > >> > {% endfor %}{% endif %} returned {{ reps.paginator.count }} >> > span> result(s) > >> > > >> > {% for object in reps.object_list %} > >> > {{ object.Position }} {{ object.First_Name }} > >> > {{ object.Last_Name }} http://django.newsok.com/government/ > >> > reps/{{ object.Last_Name }}_{{ object.First_Name}}">view more > >> > {% endfor %} > >> > > > >> > > >> > {% if reps.has_previous %} > >> > >> > href="={{ reps.previous_page_number }}">Previous > >> > {% else %} > >> > Previous > >> > {% endif %} > > >> > {% if reps.has_next %} > >> > Next >> > a> > >> > {% else %} > >> > Next > >> > {% endif %} > >> > > > >> > That href is the cause of the problem, how do I pass a page to the url > >> > without resetting the query? > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "Django users" group. > >> > To post to this group, send email to django-us...@googlegroups.com. > >> > To unsubscribe from this group, send email to > >> > django-users+unsubscr...@googlegroups.com. > >> > For more options, visit this group > >> > athttp://groups.google.com/group/django-users?hl=en. > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Django users" group. > >> To post to this group, send email to django-us...@googlegroups.com. > >> To unsubscribe from this group, send email to > >>
Weird inconsistencies for same queryset in different Django instances
Hi, I've run into a weird bug that has me scratching my head - I'm seeing inconsistent results from a queryset between various apache processes and the django shell. I.e. sometimes a GET gives me the right response (as it hits a "correct" Apache instance) and other times it gives a wrong response. Restarting Apache causes problem to go away, but it resurfaces later. I have a Poll class which has a start_time and an end_time, both of which are optional, plus an enabled field. A poll is considered active if it's enabled, and if it has a start_time then now > start_time, and if it has an end_time then now < end_time. What I'm seeing is that sometimes polls with a start_time that is before now are not showing up in the responses when I do a series of GETs. So e.g. first GET - shows poll, second one - doesn't show, third - doesn't, fourth - does and so on. >From a fresh python shell, the Poll.objects.active() call always gives the right results. The code in question is: class PollManager(models.Manager): def active(self): qs = super(PollManager, self).get_query_set().filter(enabled=True) q_start = Q(start_time__isnull=True) | Q(start_time__lte=datetime.datetime.now()) q_end = Q(end_time__isnull=True) | Q(end_time__gte=datetime.datetime.now()) return qs.filter(q_start,q_end) Where the models are is: class Event(models.Model): enabled = models.BooleanField() # automatic default false other fields class Poll(models.Model): event = models.ForeignKey(Event, db_index=True) enabled = models.BooleanField() # automatic default false start_time = models.DateTimeField(blank=True, null=True, help_text="Time to enable this poll (optional)") end_time = models.DateTimeField(blank=True, null=True, help_text="Time to close this poll (optional)") objects = PollManager() The view logic is basically: def view_polls(request, event_id): filtered_set = self.queryset._clone()# Queryset is Poll.objects.active().filter(event__enabled = True) filtered_set = filtered_set.filter(event__id=event_id) return render_to_response(template, filtered_set) (this has been elided and adapted - original code is using django-rest-api, JSON responder etc. But the call boils down to this) I'm confused as to what the problem could be - any clues? Cheers, Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is passing values into the admin add page possible?
ah nice one Jason :) sorry it took me a while to respond, I had a load more problems and I sort of forgot about this one I didn't get your solution working, but while I was hacking away and searching the net for ideas I found request.GET.get('q', '') in http://stackoverflow.com/questions/150505/django-capturing-url-parameters-in-request-get and multiple url params in: http://stackoverflow.com/questions/2364700/django-url-parameter-key-used-twice I then realise that I was already overriding the admin models get_form() which has the request parameter, so it was simply a matter of setting the initial state of the field via: initial=doc_no and passing in the parameters via: add/?doc_no=Test1_desc=Test2 and Test1 and Test2 ended up in the correct boxes :), I'm a bit new to web dev stuff so have never used url parameters, so I'm glad it was this easy, only took about ten mins :) I've no idea if this is the right way to do what I wanted, but it works, here's the code class MyModelAdmin(admin.ModelAdmin): ... def get_form(self, request, obj=None): """override some widgets for the admin change form""" form = super(MyModelAdmin, self).get_form(request, obj) doc_no = request.GET.get('doc_no', '') doc_desc = request.GET.get('doc_desc', '') form.base_fields['doc_no'] = forms.CharField( widget=forms.Textarea(), initial=doc_no) form.base_fields['doc_desc'] = forms.CharField( widget=forms.Textarea(), initial=doc_desc) return form Thanks again Jason! On May 9, 3:44 pm, leveillewrote: > On May 9, 4:58 am, nih wrote: > > > I've got a python program that starts up a django web app, I'm trying > > to figure out how to pass values from the program to the web app so > > some fields in the admin add page are automatically populated with > > values from the program, is the only way via url parameters?, I sense > > its a lot more complicated than that :-) > > Hi, Steve, > > I've overridden render_change_form in the past to add extra context to > a change form for one of my admin classes. I've pasted a quick > example here:http://dpaste.com/hold/192434/. This method can be > found in the ModelAdmin base > class:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm > Of course, because request is passed to this method, you can access > GET, etc. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django takes all my toys
It sounds like Django is working and your issue is with the web server configuration. In you case it sounds like there are two ways you could install Django, add a virtual host to the machine, or configure apache to serve Django from a subdirectory. Unless you have extra hostnames available, I'd go with the subdirectory option. Both configuration options have examples on the web. On May 10, 2010, at 6:31 PM, ah...@cs.ucla.edu wrote: > Hi, > > I don't know very much about django, except that a piece of software > that one of my colleagues developed requires it to function properly. > > My problem is as follows : I have inherited responsibility for > installing the aforementioned software on a pre-existing webserver > which already hosts more than one site. The server has been installed > and maintained by an ad-hoc group of researchers, insofar as I can > determine. I need to install deploy Django for the piece of software > on this server without clobbering any pre-existing websites. > > I have successfully* installed and configured** Django with Apache and > mod_wsgi and Python2.6 on a CentOS machine. However, when I enable > django in the apache configuration file, one of two things happens : > (1) the congratulations you installed django page appears on all or > most webpages on the server (2) the congratulations you installed > Django page is inaccessible. > > Neither of these outcomes solves my problems... > > What would be the recommended way to allow django and the rest of the > sites to coexist? Do I need virtual hosts and a separate URL? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Tests fail with django-1.2-rc1
Am Dienstag 11 Mai 2010, 16:38:40 schrieb Russell Keith-Magee: > On Tue, May 11, 2010 at 10:21 PM, Dirk Eschlerwrote: > > Hello, > > > > i'm in the process of upgrading a project to django-1.2-rc1. While the > > project specific tests passed with django-1.1.1, they all fail now with > > django-1.2-rc1 (see example below). Any idea what's going wrong? > > At a guess -- you have a model with a custom save() method that isn't > correctly handling optional arguments. In Django 1.1, save() only took > two arguments: force_insert=False and force_update=False. Django 1.2 > added a new argument to save (the ``using`` argument) in order to > handle multiple databases. > > The Django docs recommended [1] using (*args, **kwargs) to allow for > the addition of future arguments to save(); if you explicitly included > support for force_insert and force_update, you will need to update > your save() method to support the new using argument as well (or, > better still - take the opportunity to migrate to using > (*args,**kwargs) ) Good guess. :) And thanks for the pointer regarding additional arguments. I have fixed my save methods and the tests pass again. Best Regards, Dirk Eschler -- Dirk Eschler http://www.krusader.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django version 1.1.1 decimalfield invalidoperation
On Tue, May 11, 2010 at 9:49 AM, mendes.rich...@gmail.com < mendes...@gmail.com> wrote: > On our production server we are running the last official release > 1.1.1, > When i started uploading big decimal values i ran into trouble and > came across a ticket which described the error. > > This was ticket 10692 and it was solved. > > Unfortunately i couldn't track down which files should be replaced by > the altered code from the ticket. > Could anyone help me out and explain me how this normally works > outside the svn repository, so which files should i replace and where > can i find the altered code for those parts. > > your help would be greatly appreciated, > > Ticket #10692: http://code.djangoproject.com/ticket/10692 includes comments linking to the changesets where it was fixed, for example on trunk: http://code.djangoproject.com/changeset/10545 shows the files and exact changes that were made. Note however, this ticket was fixed in trunk and the 1.0.X branch, which implies that the fix already exists in the 1.1 (and all subsequent) releases. The changes include a test of the problem that was fixed, and that tests passes in 1.1.1 and current trunk. Thus you should not be seeing this problem if you are running 1.1.1. Perhaps if you described exactly what problem you are seeing, including the version of Python you are running, someone could help in figuring out what is going on. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: MacPorts installation, Django $PATH issue
The quick answer for MacPorts python: 1) Edit the file /Users//.bash_profile. Add the following line below the line "export ENV", or to the end of the file if you don't see that line: "export PATH=/opt/local/bin:/opt/local/sbin:$PATH" 2) At the command prompt run "python_select -l" This will show you a list of python versions you can select. Pick one, let's say python 2.6, and run "python_select python26" 3) Run "which python" and you should get "/opt/local/bin/python". If not, then something else is wrong. The long answer: There are two potential problems here, both related to MacPorts. One, if the directories /opt/local/bin and /opt/local/sbin aren't in the $PATH environment variable, then bash (the program that you are using when you're working on the command line) doesn't know where to find the macports version of python. Two, if you don't run "python_select" then your system is still going to run the built-in version of python, because macports names the python executable pythonXY, where XY is the version (24, 25 or 26). Both of these issues are caused by MacPorts being very careful not to screw up your computer, which is good, but at the cost of a more complicated setup, which is confusing for new users. I hope that helps, and if you'd like more explanation of bash and the details of what's going on with the $PATH variable, then I suggest checking out this "Bash by example" series of articles. http://www.ibm.com/developerworks/library/l-bash.html On May 10, 2010, at 10:24 AM, HelloWorld wrote: > So for future users who have the same problem. > > I uninstalled the macports version of django with this: > > sudo port -f uninstall > > and then reinstalled with easy setup which automatically puts the > django package in the correct place. > > Now everything worked as described in the tutorial. > > Could be worthwhile for macports or anybody who used macports, to post > the correct way to install with macports and What the benefit is to > use macports over django. > > Best > > Z. > > > > On May 10, 1:13 pm, HelloWorldwrote: >> Thanks a lot backdoc!! >> >> I found the site packages you mentioned, but neither Python 2.5 nor >> 2.6 have any django in it. >> I know that on the commandline it is running version 2.5 and django is >> freshly installed and so could need 2.6. >> How could I install it there? >> >> I start to think the Macports installation is the problem. >> Is there any way to uninstall everything and reinstall with easy setup >> from django? >> As I read this is the prerequisite to install a new version. >> >> What wonders me is that it did everything else, create the manage, >> _init__ , settings, urls.py >> Do I miss something really obvious? >> >> And as a matter of fact I am starting to understand python and django, >> so please excuse any newbie errors. >> >> Thanks a again for the help >> >> Best >> >> Z. >> >> On May 6, 11:53 pm, backdoc wrote: >> >> >> >>> Type "which python" at the command line as your regular user. Then, look at >>> /usr/bin/python*, /usr/lib, /usr/local/bin/python* and /usr/local/lib. >>> Find where the site-packages for Django are located. Make sure that "which >>> python" is pointing to the correct version. >> >>> Sounds like Django is not installed in the same version of Python that you >>> are actually using. Also, if you type python -V (I think it's a capital >>> "V") at the command line, it should tell you which version you are using. >> >>> On Thu, May 6, 2010 at 3:47 AM, HelloWorld wrote: Hi everybody >> I just got Django installed (to test it) via Macports and I have Python 2.5 and 2.6 installed on a MacBook running 10.6.3. >> I did everything the installation guide told me, but after typing: >> python manage.py runserver >> I get this error: >> File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management >> I believe the solution would be this comment on the installation site: >> To avoid a command not found issue with Snow Leopard 10.6.2 and various other OSX (Django installed using MacPorts?) here a tip that might help. There might be a $PATH issue. Adding the proper PATH to ~/.Profile: export PATH=/opt/local/bin:opt/local/sbin:/opt/local/lib/ python2.4/site-packages/django/bin:$PATH should help. NB Could be that one needs to change the Python version in the PATH. >> But I dont now what a $PATH issue is and where I could paste this code to fix it. >> Or if you know another possible reason please tell me. >> Any help would be greatly appreciated. >> Thanks a lot >> Best >> Z. >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send
Re: Tests fail with django-1.2-rc1
On Tue, May 11, 2010 at 10:21 PM, Dirk Eschlerwrote: > Hello, > > i'm in the process of upgrading a project to django-1.2-rc1. While the project > specific tests passed with django-1.1.1, they all fail now with django-1.2-rc1 > (see example below). Any idea what's going wrong? At a guess -- you have a model with a custom save() method that isn't correctly handling optional arguments. In Django 1.1, save() only took two arguments: force_insert=False and force_update=False. Django 1.2 added a new argument to save (the ``using`` argument) in order to handle multiple databases. The Django docs recommended [1] using (*args, **kwargs) to allow for the addition of future arguments to save(); if you explicitly included support for force_insert and force_update, you will need to update your save() method to support the new using argument as well (or, better still - take the opportunity to migrate to using (*args,**kwargs) ) [1] http://docs.djangoproject.com/en/1.1/topics/db/models/#overriding-model-methods Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Paginating search results
Great, Just make sure you don't end up with multiple "page" arguments on your query string when navigating through the results (click next; click next again...). Nuno On Tue, May 11, 2010 at 2:41 PM, Nickwrote: > The POST thing was the result of late night meltdowns and desperation. > I tend to just try stupid things when i'm working through an issue > like this, just seeing what the application is capable of doing. I've > switched it all back to GET. > > I found the answer around 1 this morning. You are exactly right, I > needed to capture the query string and place it in the "next" and > "previous" page links. Here's how I went about doing that, just in > case someone else runs into this issue: > > query_string = request.GET.copy() > > and then in the dict: > > 'query_string': query_string.urlencode() > > > > > > On May 11, 4:46 am, Nuno Maltez wrote: >> You need to pass the current search paramters in your query string >> (?party=D== ) when you create the links to all the >> pages, and you need to be able to retrieve them from request.GET in >> order to recreate the object list (reps) when rendering a specific >> page (any particular reason why are you using POST in the search >> form?). >> >> hth, >> Nuno >> >> >> >> On Tue, May 11, 2010 at 1:58 AM, Nick wrote: >> > I'm trying to paginate results from a search with multiple options. >> > The only problem is, once I hit the next button it clears the query >> > and I'm left paginating all the objects in the DB. >> >> > Here is my view: >> >> > def filter_search(request): >> > if request.POST: >> > reps = Rep.objects.all() >> > else: >> > reps = [] >> > query = request.POST >> > if 'q' in request.POST: >> > q = request.POST.get('q', '') >> > qset = ( >> > Q(Last_Name__icontains=q) | Q(First_Name__icontains=1) >> > ) >> > reps = reps.filter(qset) >> > else: >> > q = [] >> > if len(q): >> > qlist = q >> > else: >> > qlist = [] >> > if 'party' in request.POST: >> > party = request.POST.getlist('party') >> > reps = reps.filter(Party__in=party) >> > else: >> > party = [] >> > if len(party): >> > plist = party >> > else: >> > plist = [] >> > paginator = Paginator(reps, 15) >> > results = paginator.count >> > try: >> > page = int(request.POST.get('page', '1')) >> > except: >> > page = 1 >> > try: >> > repList = paginator.page(page) >> > except (EmptyPage, InvalidPage): >> > repList = paginator.page(paginator.num_pages) >> > finalq = request.POST >> > return render_to_response("Government/search.html", { >> > 'reps': repList, >> > 'query': query, >> > 'plist': plist, >> > 'qlist': qlist, >> > 'results': results, >> > 'finalq': finalq >> > }) >> >> > Here is my tpl: >> >> > >> > >> > Democrat >> > Republican >> > >> > >> >> > {% if query %} >> > Your search for {% if qlist %} {{ qlist}} {% endif %} >> > {% if plist %} {% for p in plist %} {% if forloop.first %} Party >> > ({{ p }}) {% else %} & Party ({{p}}) {% endif %} >> > {% endfor %}{% endif %} returned {{ reps.paginator.count }}> > span> result(s) >> > >> > {% for object in reps.object_list %} >> > {{ object.Position }} {{ object.First_Name }} >> > {{ object.Last_Name }} http://django.newsok.com/government/ >> > reps/{{ object.Last_Name }}_{{ object.First_Name}}">view more >> > {% endfor %} >> > >> >> > >> > {% if reps.has_previous %} >> > > > href="={{ reps.previous_page_number }}">Previous >> > {% else %} >> > Previous >> > {% endif %} >> >> > {% if reps.has_next %} >> > Next> > a> >> > {% else %} >> > Next >> > {% endif %} >> > >> >> > That href is the cause of the problem, how do I pass a page to the url >> > without resetting the query? >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group >> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to >
Tests fail with django-1.2-rc1
Hello, i'm in the process of upgrading a project to django-1.2-rc1. While the project specific tests passed with django-1.1.1, they all fail now with django-1.2-rc1 (see example below). Any idea what's going wrong? ERROR: test_content_is_active (foo.bar.tests.MyTestCase) -- Traceback (most recent call last): File "/path/to/myproject/site-packages/foo/bar/tests.py", line 35, in setUp status=status) File "/path/to/myproject/site-packages/django/db/models/manager.py", line 138, in create return self.get_query_set().create(**kwargs) File "/path/to/myproject/site-packages/django/db/models/query.py", line 352, in create obj.save(force_insert=True, using=self.db) TypeError: save() got an unexpected keyword argument 'using' Best Regards, Dirk Eschler -- Dirk Eschler-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
On Tue, May 11, 2010 at 6:15 AM, HelloWorldwrote: > Hi Jirka > > Thanks for your answer! > > By structure I mean, I just followed the tutorial and am not sure if > the position and order of these tutorial code is right in my code: > > class Poll(models.Model): ># ... > def __unicode__(self): >return self.question > > class Choice(models.Model): ># ... >def __unicode__(self): >return self.choice > > > AND > > import datetime > # ... > class Poll(models.Model): ># ... > def was_published_today(self): >return self.pub_date.date() == datetime.date.today() > > If you are saying that you repeated the "class Poll" line, first with the __unicode__ method defined and then later with the was_published_today method, you are right that that is incorrect. The "class Poll(model.Model):" line should appear only once in the file, and indented beneath it should be all of the fields and methods for the Poll model. If you repeat "class Poll...", then whatever follows that line will completely replace the previous definition for the Poll class, which is not what you want, and would lead to the result you show (no apparent definition of the __unicode__ method for Poll, since you overwrite the Poll-with-unicode version with the Poll-with-was_published_today version). Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: processing page
This was recently discussed on this list: http://groups.google.com/group/django-users/browse_thread/thread/7cefcb64dd423ef2/ Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Updating profiles
Is AUTH_PROFILE_MODULE set correctly in settings.py? On Tue, May 11, 2010 at 6:43 AM, django_jediwrote: > OK, I'm baffled. I must be missing something right in front of my > face... > > I'm trying to create a form that will allow users to update their > profiles. No matter what I try, I get a > > "User matching query does not exist." > > ...error. Below is the associated view, and the related model and > form clases. Any help would be appreciated. > > > > VIEW > --- > @login_required > def update_profile(request): > try: > myprofile = request.user.get_profile() > except: > up = Profile(user=request.user) > up.save() > myprofile = request.user.get_profile() > > if request.method == 'POST': > form = ProfileUpdateForm(request.POST, request.FILES, > instance=myprofile) > if form.is_valid(): > form.save() > else: > form = ProfileUpdateForm(instance=myprofile) > > return render_to_response('profiles/update.html', {'form':form, > 'profile':myprofile}, > context_instance = RequestContext(request)) > > MODEL > --- > class Profile(models.Model): > # This is the only required field > user = models.ForeignKey(User, unique=True) > picture = models.ImageField(upload_to='img/profilepics/%Y%m%d/', > blank=True, null=True) > # The rest is completely up to you... > favorite_band = models.CharField(max_length=100, blank=True) > favorite_cheese = models.CharField(max_length=100, blank=True) > lucky_number = models.IntegerField(null=True, blank=True) > > > FORM > --- > class ProfileUpdateForm(ModelForm): > class Meta: > model = Profile > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django version 1.1.1 decimalfield invalidoperation
Hello Django Users, On our production server we are running the last official release 1.1.1, When i started uploading big decimal values i ran into trouble and came across a ticket which described the error. This was ticket 10692 and it was solved. Unfortunately i couldn't track down which files should be replaced by the altered code from the ticket. Could anyone help me out and explain me how this normally works outside the svn repository, so which files should i replace and where can i find the altered code for those parts. your help would be greatly appreciated, regards, Richard Mendes -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Paginating search results
The POST thing was the result of late night meltdowns and desperation. I tend to just try stupid things when i'm working through an issue like this, just seeing what the application is capable of doing. I've switched it all back to GET. I found the answer around 1 this morning. You are exactly right, I needed to capture the query string and place it in the "next" and "previous" page links. Here's how I went about doing that, just in case someone else runs into this issue: query_string = request.GET.copy() and then in the dict: 'query_string': query_string.urlencode() On May 11, 4:46 am, Nuno Maltezwrote: > You need to pass the current search paramters in your query string > (?party=D== ) when you create the links to all the > pages, and you need to be able to retrieve them from request.GET in > order to recreate the object list (reps) when rendering a specific > page (any particular reason why are you using POST in the search > form?). > > hth, > Nuno > > > > On Tue, May 11, 2010 at 1:58 AM, Nick wrote: > > I'm trying to paginate results from a search with multiple options. > > The only problem is, once I hit the next button it clears the query > > and I'm left paginating all the objects in the DB. > > > Here is my view: > > > def filter_search(request): > > if request.POST: > > reps = Rep.objects.all() > > else: > > reps = [] > > query = request.POST > > if 'q' in request.POST: > > q = request.POST.get('q', '') > > qset = ( > > Q(Last_Name__icontains=q) | Q(First_Name__icontains=1) > > ) > > reps = reps.filter(qset) > > else: > > q = [] > > if len(q): > > qlist = q > > else: > > qlist = [] > > if 'party' in request.POST: > > party = request.POST.getlist('party') > > reps = reps.filter(Party__in=party) > > else: > > party = [] > > if len(party): > > plist = party > > else: > > plist = [] > > paginator = Paginator(reps, 15) > > results = paginator.count > > try: > > page = int(request.POST.get('page', '1')) > > except: > > page = 1 > > try: > > repList = paginator.page(page) > > except (EmptyPage, InvalidPage): > > repList = paginator.page(paginator.num_pages) > > finalq = request.POST > > return render_to_response("Government/search.html", { > > 'reps': repList, > > 'query': query, > > 'plist': plist, > > 'qlist': qlist, > > 'results': results, > > 'finalq': finalq > > }) > > > Here is my tpl: > > > > > > > Democrat > > Republican > > > > > > > {% if query %} > > Your search for {% if qlist %} {{ qlist}} {% endif %} > > {% if plist %} {% for p in plist %} {% if forloop.first %} Party > > ({{ p }}) {% else %} & Party ({{p}}) {% endif %} > > {% endfor %}{% endif %} returned {{ reps.paginator.count }} > span> result(s) > > > > {% for object in reps.object_list %} > > {{ object.Position }} {{ object.First_Name }} > > {{ object.Last_Name }} http://django.newsok.com/government/ > > reps/{{ object.Last_Name }}_{{ object.First_Name}}">view more > > {% endfor %} > > > > > > > {% if reps.has_previous %} > > > href="={{ reps.previous_page_number }}">Previous > > {% else %} > > Previous > > {% endif %} > > > {% if reps.has_next %} > > Next > a> > > {% else %} > > Next > > {% endif %} > > > > > That href is the cause of the problem, how do I pass a page to the url > > without resetting the query? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
processing page
I am new to django, so far I have designed a webpage that uploads a file and accesses some python code which does a task on the file and then outputs the results onto a results page. However, this process can take a couple of minutes so would like to inform the user of this using a processing or 'please wait' page. Is this possible? and if so how? Many Thanks for your help rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to display an image inside Django
On May 11, 7:10 am, ravi krishnawrote: > Hi, > I am a beginner in Django . > Can somebody tel me how to display an image in django... > if anyone has the right tutorial for beginners, please share with me.. > -- > Regards, > Rav! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. Are you uploading the image with ImageField? If so, the ImageField attribute in your model will have image related data that you will be able to access in a template: http://docs.djangoproject.com/en/dev/topics/files/#topics-files. Also, you can always just insert an image directly in your template. Something like: If you are really green and just need a place to get started, I would recommend the intro tutorial: http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
On May 11, 11:15 am, HelloWorldwrote: > Hi Jirka > > Thanks for your answer! > > By structure I mean, I just followed the tutorial and am not sure if > the position and order of these tutorial code is right in my code: > > class Poll(models.Model): > # ... > def __unicode__(self): > return self.question > > class Choice(models.Model): > # ... > def __unicode__(self): > return self.choice > > AND > > import datetime > # ... > class Poll(models.Model): > # ... > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > > And I know the result is wrong because in the API it does not return > what the tutorial says should be returned: > > TUTORIAL: > > >>> from mysite.polls.models import Poll, Choice > > # Make sure our __unicode__() addition worked.>>> Poll.objects.all() > > [] > > ME: > > >>> Poll.objects.all() > > [] > > Thanks for the time! > > Best > > Z. A simple suggestion: have you quit and reloaded the shell? -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to display an image inside Django
Hi, I am a beginner in Django . Can somebody tel me how to display an image in django... if anyone has the right tutorial for beginners, please share with me.. -- Regards, Rav! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Form multiple inheritance
Hi I've got two ModelForms, both really simple. class TaskBaseForm(forms.ModelForm): class Meta: model = Task class TaskAssignmentDurationForm(forms.ModelForm): """ Form for setting the duration of an existing TaskAssignment object. """ class Meta: model = TaskAssignment fields = [ "days", "hours" ] class TaskUberForm(TaskBaseForm): """ Using the magic of multiple inheritance we can combine our two forms to create a new form that makes sense to the user and presents the disparative data models in a nice way. """ __metaclass__ = getMixupFormMetaClass() I then define a third form that inherits from both, making use of the classmaker[1] factory to get rid of any multi inheritance issues. The new form that I've created then won't display any of the second form's fields. Any ideas how I can get this to work? I've looked at this ticket: http://code.djangoproject.com/ticket/7018 , implementing the last resolution to solve the issue. [1]And I've implemented the classmaker: http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/ I feel like I'm missing something obvious here? Many Thanks in Advance, Dan -- Dan Hilton www.twitter.com/danhilton www.DanHilton.co.uk -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
Hmm, I can't see anything wrong with your code, so I'm gonna go to the basics - how about your code indentation? Is the "def __unicode__()" the same way as your model field definitions? The __unicode__() function must be part of your Poll class, not standalone. Cheers Jirka On 11/05/2010, HelloWorldwrote: > Hi Jirka > > Thanks for your answer! > > By structure I mean, I just followed the tutorial and am not sure if > the position and order of these tutorial code is right in my code: > > class Poll(models.Model): > # ... > def __unicode__(self): > return self.question > > class Choice(models.Model): > # ... > def __unicode__(self): > return self.choice > > > AND > > import datetime > # ... > class Poll(models.Model): > # ... > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > > > And I know the result is wrong because in the API it does not return > what the tutorial says should be returned: > > TUTORIAL: > from mysite.polls.models import Poll, Choice > > # Make sure our __unicode__() addition worked. Poll.objects.all() > [] > > > ME: > Poll.objects.all() > [] > > Thanks for the time! > > Best > > Z. > > > > > On May 11, 12:03 pm, Jirka Vejrazka wrote: >> > class Choice(models.Model): >> > poll = models.ForeignKey(Poll) >> > choice = models.CharField(max_length=200) >> > votes = models.IntegerField() >> > def __unicode__(self): >> > return self.question >> >> > I know the structure is wrong. >> > Any suggestions would be greatly appreciated. >> >> Hi, >> >> I'm not sure why you'd think the structure is wrong (i.e. state >> actual errors or problems rather than generic statements). >> >> However there is one problem with your Choice model. It does not >> have any self.question, so __unicode__() can't really return it. You >> probaby want to use "return self.choice" there (or compose some text >> string based on existing model fields). >> >> HTH >> >> Jirka >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group >> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Loading picasa photo's with syncr
I now hacked it like this: updated = datetime(*strptime(album.updated.text[:-5], "%Y-%m-%dT%H:%M:%S")[:7]) not very pretty imho. But its stable, and I don't know a better way. Grtz, Dexter On Tue, May 11, 2010 at 12:02 PM, Dexterwrote: > Hi everyone, > > I want to populate my db using syncr, > But when I run "python manage.py syncr_picasaweb", I get the following > error : > > Traceback (most recent call last): > File "manage.py", line 11, in > execute_manager(settings) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/__init__.py", > line 438, in execute_manager > utility.execute() > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/__init__.py", > line 379, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/base.py", > line 191, in run_from_argv > self.execute(*args, **options.__dict__) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/base.py", > line 218, in execute > output = self.handle(*args, **options) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/picasaweb/management/commands/sync_picasaweb.py", > line 55, in handle > ps.syncAllAlbums(username=picasaweb_user) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/app/picasaweb.py", > line 225, in syncAllAlbums > self.syncAlbum(album) > File "/home/site/domains/ > jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/app/picasaweb.py", > line 166, in syncAlbum > updated = datetime(*strptime(album.updated.text, > "%Y-%m-%dT%H:%M:%S.000Z")[:7]) > File "/usr/lib/python2.5/_strptime.py", line 330, in strptime > (data_string, format)) > ValueError: time data did not match format: data=2009-12-23T14:26:34.825Z > fmt=%Y-%m-%dT%H:%M:%S.000Z > > Do you know how I can format the format so the .***Z is catched? > > Grtz, Dexter > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Updating profiles
OK, I'm baffled. I must be missing something right in front of my face... I'm trying to create a form that will allow users to update their profiles. No matter what I try, I get a "User matching query does not exist." ...error. Below is the associated view, and the related model and form clases. Any help would be appreciated. VIEW --- @login_required def update_profile(request): try: myprofile = request.user.get_profile() except: up = Profile(user=request.user) up.save() myprofile = request.user.get_profile() if request.method == 'POST': form = ProfileUpdateForm(request.POST, request.FILES, instance=myprofile) if form.is_valid(): form.save() else: form = ProfileUpdateForm(instance=myprofile) return render_to_response('profiles/update.html', {'form':form, 'profile':myprofile}, context_instance = RequestContext(request)) MODEL --- class Profile(models.Model): # This is the only required field user = models.ForeignKey(User, unique=True) picture = models.ImageField(upload_to='img/profilepics/%Y%m%d/', blank=True, null=True) # The rest is completely up to you... favorite_band = models.CharField(max_length=100, blank=True) favorite_cheese = models.CharField(max_length=100, blank=True) lucky_number = models.IntegerField(null=True, blank=True) FORM --- class ProfileUpdateForm(ModelForm): class Meta: model = Profile -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
Hi Jirka Thanks for your answer! By structure I mean, I just followed the tutorial and am not sure if the position and order of these tutorial code is right in my code: class Poll(models.Model): # ... def __unicode__(self): return self.question class Choice(models.Model): # ... def __unicode__(self): return self.choice AND import datetime # ... class Poll(models.Model): # ... def was_published_today(self): return self.pub_date.date() == datetime.date.today() And I know the result is wrong because in the API it does not return what the tutorial says should be returned: TUTORIAL: >>> from mysite.polls.models import Poll, Choice # Make sure our __unicode__() addition worked. >>> Poll.objects.all() [] ME: >>> Poll.objects.all() [] Thanks for the time! Best Z. On May 11, 12:03 pm, Jirka Vejrazkawrote: > > class Choice(models.Model): > > poll = models.ForeignKey(Poll) > > choice = models.CharField(max_length=200) > > votes = models.IntegerField() > > def __unicode__(self): > > return self.question > > > I know the structure is wrong. > > Any suggestions would be greatly appreciated. > > Hi, > > I'm not sure why you'd think the structure is wrong (i.e. state > actual errors or problems rather than generic statements). > > However there is one problem with your Choice model. It does not > have any self.question, so __unicode__() can't really return it. You > probaby want to use "return self.choice" there (or compose some text > string based on existing model fields). > > HTH > > Jirka > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
> class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(max_length=200) > votes = models.IntegerField() > def __unicode__(self): > return self.question > > > I know the structure is wrong. > Any suggestions would be greatly appreciated. Hi, I'm not sure why you'd think the structure is wrong (i.e. state actual errors or problems rather than generic statements). However there is one problem with your Choice model. It does not have any self.question, so __unicode__() can't really return it. You probaby want to use "return self.choice" there (or compose some text string based on existing model fields). HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Loading picasa photo's with syncr
Hi everyone, I want to populate my db using syncr, But when I run "python manage.py syncr_picasaweb", I get the following error : Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/django/core/management/base.py", line 218, in execute output = self.handle(*args, **options) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/picasaweb/management/commands/sync_picasaweb.py", line 55, in handle ps.syncAllAlbums(username=picasaweb_user) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/app/picasaweb.py", line 225, in syncAllAlbums self.syncAlbum(album) File "/home/site/domains/ jcdedukdalf.nl/jcdedukdalf.nl/lib/python2.5/site-packages/syncr/app/picasaweb.py", line 166, in syncAlbum updated = datetime(*strptime(album.updated.text, "%Y-%m-%dT%H:%M:%S.000Z")[:7]) File "/usr/lib/python2.5/_strptime.py", line 330, in strptime (data_string, format)) ValueError: time data did not match format: data=2009-12-23T14:26:34.825Z fmt=%Y-%m-%dT%H:%M:%S.000Z Do you know how I can format the format so the .***Z is catched? Grtz, Dexter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Models Tutorial Django
Hi everybody I have to excuse myself for the newbie question which is following now: Now I am doing the Poll/Models Tutorial on this page http://docs.djangoproject.com/en/dev/intro/tutorial01/ and I am stuck at this point: Wait a minute. is, utterly, an unhelpful representation of this object. Let's fix that by editing the polls model (in the polls/models.py file) and adding a __unicode__() method to both Poll and Choice: I changed the code in the models.py to this: import datetime from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.question I know the structure is wrong. Any suggestions would be greatly appreciated. Thanks!! Best Z -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Paginating search results
You need to pass the current search paramters in your query string (?party=D== ) when you create the links to all the pages, and you need to be able to retrieve them from request.GET in order to recreate the object list (reps) when rendering a specific page (any particular reason why are you using POST in the search form?). hth, Nuno On Tue, May 11, 2010 at 1:58 AM, Nickwrote: > I'm trying to paginate results from a search with multiple options. > The only problem is, once I hit the next button it clears the query > and I'm left paginating all the objects in the DB. > > Here is my view: > > def filter_search(request): > if request.POST: > reps = Rep.objects.all() > else: > reps = [] > query = request.POST > if 'q' in request.POST: > q = request.POST.get('q', '') > qset = ( > Q(Last_Name__icontains=q) | Q(First_Name__icontains=1) > ) > reps = reps.filter(qset) > else: > q = [] > if len(q): > qlist = q > else: > qlist = [] > if 'party' in request.POST: > party = request.POST.getlist('party') > reps = reps.filter(Party__in=party) > else: > party = [] > if len(party): > plist = party > else: > plist = [] > paginator = Paginator(reps, 15) > results = paginator.count > try: > page = int(request.POST.get('page', '1')) > except: > page = 1 > try: > repList = paginator.page(page) > except (EmptyPage, InvalidPage): > repList = paginator.page(paginator.num_pages) > finalq = request.POST > return render_to_response("Government/search.html", { > 'reps': repList, > 'query': query, > 'plist': plist, > 'qlist': qlist, > 'results': results, > 'finalq': finalq > }) > > Here is my tpl: > > > > > Democrat > Republican > > > > {% if query %} > Your search for {% if qlist %} {{ qlist}} {% endif %} > {% if plist %} {% for p in plist %} {% if forloop.first %} Party > ({{ p }}) {% else %} & Party ({{p}}) {% endif %} > {% endfor %}{% endif %} returned {{ reps.paginator.count }} span> result(s) > > {% for object in reps.object_list %} > {{ object.Position }} {{ object.First_Name }} > {{ object.Last_Name }} http://django.newsok.com/government/ > reps/{{ object.Last_Name }}_{{ object.First_Name}}">view more > {% endfor %} > > > > > {% if reps.has_previous %} > href="={{ reps.previous_page_number }}">Previous > {% else %} > Previous > {% endif %} > > > {% if reps.has_next %} > Next a> > {% else %} > Next > {% endif %} > > > > That href is the cause of the problem, how do I pass a page to the url > without resetting the query? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Specifying an order_with_respect_to for a self referential one to many relationship (still) fails
On Tue, May 11, 2010 at 5:18 PM, thierrywrote: > This bug is 4 years old. Weird that It was not corrected yet because > it seems to be a core functionality of the ORM. Do django developpers > have planned something before 1.2 stable release ? No, we don't have anything planned before 1.2 goes final. The release candidate released last week contains all the features and bugfixes that will be in the final release, with the exception of any critical bugs found between now and the final release (there have been 2 confirmed, and possibly a third reported so far). order_with_respect_to may be part of the ORM, and it certainly has bugs, but those bugs have been present for a long time - they're not a critical bug by our release process. To tell the truth, I only learned about the existence of order_with_respect_to when a bug was reported recently in the way order_with_respect_to interacted with another newly added feature. That possibly goes some way to explaining why the bug you describe has lingered for so long. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Specifying an order_with_respect_to for a self referential one to many relationship (still) fails
This bug is 4 years old. Weird that It was not corrected yet because it seems to be a core functionality of the ORM. Do django developpers have planned something before 1.2 stable release ? Regards, Thierry. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Sqlite
Thanks a million Romain!! It worked. I thought about just naming it, but in the tutorial it said put the path and I didnt want to mess up things. Thanks again!! Best Z. On May 11, 10:37 am, Romain Gacheswrote: > Le 11 mai 2010 à 10:30, HelloWorld a écrit : > > > Hi Everybody > > > I installed Django and wanted to test what I can do by using Sqlite. > > It is unclear for me how this can be achieved and therefore have the > > following open questions: > > > 1. Do I need to fill in the settings.py any other info than: > > django.db.backends.sqlite3 at ENGINE > > What do I/ Do I need to fill in in NAME, USER, HOST an where can I > > create the PASSWORD. > > All you need is the ENGINE and NAME (path to your db file). > As Sqlite isn't a C/S engine, there's no host/user/password info needed. > > > 2. If Django creates the db file, where can I find it? What is the > > default name? > > It's the name you defined in the NAME parameter. > > > 3." If the file doesn't exist, it will automatically be created when > > you synchronize the database for the first time (see below)." Is this > > done by this command "python manage.py syncdb". Once you start the > > server in the commandline, it is no longer possible to enter a > > command. So I opened a new tab and typed this command and got this > > answer: > > > "Please fill out DATABASE_NAME in the settings module before using the > > database." > > > So there I am at the beginning again. > > Sqlite creates the file if it doesn't exist. But you must define the filename > in the NAME setting. > > -- > Romain Gaches > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Subclassing models.Model to extend base functionalities and attributes
No, I don't talk about model inheritance. Mainly because base class fields are propagated to subclasses. I'd like to overload some base methods of the "models.Model" class to making them available from all classes of a model. But a metaclass mechanism makes overloading impossible because it forces directly to a database model inheritance. Consequently, I will abadon this way and focus on signal dispatcher because it seems possible to trigger homemade functions happening before or after models.Model methods execution. But I stay tuned if somebody has got a solution. Regards, Thierry. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Sqlite
Le 11 mai 2010 à 10:30, HelloWorld a écrit : > Hi Everybody > > I installed Django and wanted to test what I can do by using Sqlite. > It is unclear for me how this can be achieved and therefore have the > following open questions: > > 1. Do I need to fill in the settings.py any other info than: > django.db.backends.sqlite3 at ENGINE > What do I/ Do I need to fill in in NAME, USER, HOST an where can I > create the PASSWORD. All you need is the ENGINE and NAME (path to your db file). As Sqlite isn't a C/S engine, there's no host/user/password info needed. > 2. If Django creates the db file, where can I find it? What is the > default name? It's the name you defined in the NAME parameter. > 3." If the file doesn't exist, it will automatically be created when > you synchronize the database for the first time (see below)." Is this > done by this command "python manage.py syncdb". Once you start the > server in the commandline, it is no longer possible to enter a > command. So I opened a new tab and typed this command and got this > answer: > > "Please fill out DATABASE_NAME in the settings module before using the > database." > > So there I am at the beginning again. Sqlite creates the file if it doesn't exist. But you must define the filename in the NAME setting. -- Romain Gaches -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Sqlite
Hi Everybody I installed Django and wanted to test what I can do by using Sqlite. It is unclear for me how this can be achieved and therefore have the following open questions: 1. Do I need to fill in the settings.py any other info than: django.db.backends.sqlite3 at ENGINE What do I/ Do I need to fill in in NAME, USER, HOST an where can I create the PASSWORD. 2. If Django creates the db file, where can I find it? What is the default name? 3." If the file doesn't exist, it will automatically be created when you synchronize the database for the first time (see below)." Is this done by this command "python manage.py syncdb". Once you start the server in the commandline, it is no longer possible to enter a command. So I opened a new tab and typed this command and got this answer: "Please fill out DATABASE_NAME in the settings module before using the database." So there I am at the beginning again. Thanks a lot for your time. Best Z. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to copy project folder from one folder location to another
Sorry, i fixed it! it was a case of wrong PYTHONPATH. Thanks. On May 10, 5:21 pm, Gathwrote: > Am using eclipse+pydev to build my django apps. I created a new > workspace, built a new pydev project then created an empty folder in > the new pydev project. In that empty folder i imported my old django > application. Eclipse copied all the files & folders from my old django > location to the new workspace. > > I made the necessary changes in the settings.py on my new location, > pointed the templates & data location to my new location workspace > folder. > > But when i run manage.py runserver from the new location workspace > folder, django seems to point to my old folder location. All the html > templates seems to point to the old location. > > How can i make django execute stuff in my new location? > > What am i missing? > > ** When i run the server inside eclipse, everything seems to be OK! > funny. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New User Stuck on Tutorial Part 2
On 11/05/2010 4:04pm, Mike Dewhirst wrote: On 11/05/2010 3:42pm, Old Davy wrote: On 05/10/2010 08:18 PM, Shawn Milochik wrote: Exactly what directory is your copied template in? It's most likely not in the right place. Ensure that you have a template dir that your settings knows about, and that template dir has a subdirectory called 'admin' where that file is placed. Shawn That would make the most sense, and that would be my working assumption. But I can't for the life of me see where the disconnect is. this is the string that's in the TEMPLATE_DIRS section of my settings.py file: "/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS This is mine ... # if templates are not found here look in app_name/templates TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),) This puts my templates directory in the same dir as my settings.py file. Inside it I have a sub-dir for each application for which I want templates. For example, in one of them I have ... ../templates/admin/base_site.html Which contains ... {% extends "base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %} {% block branding %} {% trans 'Mysite administration' %} {% endblock %} ... and which turns Django Admin into Mysite admin. However, the "base.html" which it extends is actually in ../templates If I wanted Mysite base_site.html to extend the real Django base.html I would have to put ... {% extends "admin/base.html" %} Just realised I could have confused you a little. So You can extend anything you want to specifically nominate but if you just nominate a bare filename the way I do with base.html in ... mysite/templates/admin/base_site.html ... base.html has to exist in TEMPLATE_DIRS (mysite/templates) If you want to extend "admin/base.html" from the above base_site.html then Django looks first in ... TEMPLATES_DIR/admin ... and if it doesn't find it then it looks in site-packages/django/contrib/admin/templates/admin Mike HTH Mike That's exactly the path that my directories show, including my idiosyncratic upper case letters. I did find the file that my poll app is referencing. Turns out it was in my '/usr/local/lib/python2.6... path instead of my home directory. So when I modified THAT file, it used my changes. However, that still doesn't help, as it's not using the file that I copied to my local directory. I suppose I can play with a few more directories and see what happens... -- Climate Pty Ltd PO Box 308 Mount Eliza Vic 3930 Australia +61 T: 03 9787 6598 M: 0411 704 143 Mike Dewhirst Certified Scrum Master -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New User Stuck on Tutorial Part 2
On 11/05/2010 4:18pm, Old Davy wrote: Thank you, Mike. That DID work! So, if I have a directory that contains the /admin/base_site.html, all I have to do is specify the containing directory. I'll need to study the actual string you used a little more closely once I get more familiar with the concepts. I can see how that would give you some added flexibility, but I'm not quite grokking the details yet. OK - here is more room for confusion ... In my settings.py ... PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)).replace('\\','/') This is Python for getting the current directory path to the file in which the above code appears. Since it is in settings.py it returns my PROJECT_ROOT. The replace() just makes it cross-platform because I work in both Windows and Linux. What follows is also in settings.py and is what makes what I said in my previous email true. Notice the comment? If filesystem loader appeared *after* the app_directories loader my previous email would have taken you right to the fairies at the end of the garden path. TEMPLATE_LOADERS = ( # filesystem ahead of app_directories looks in project before django 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', 'django.template.loaders.eggs.load_template_source', Mike Still, at least I can continue the tutorial without that "mired in the mud" feeling. Thank you very much!!! On 05/10/2010 11:04 PM, Mike Dewhirst wrote: On 11/05/2010 3:42pm, Old Davy wrote: On 05/10/2010 08:18 PM, Shawn Milochik wrote: Exactly what directory is your copied template in? It's most likely not in the right place. Ensure that you have a template dir that your settings knows about, and that template dir has a subdirectory called 'admin' where that file is placed. Shawn That would make the most sense, and that would be my working assumption. But I can't for the life of me see where the disconnect is. this is the string that's in the TEMPLATE_DIRS section of my settings.py file: "/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS This is mine ... # if templates are not found here look in app_name/templates TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),) This puts my templates directory in the same dir as my settings.py file. Inside it I have a sub-dir for each application for which I want templates. For example, in one of them I have ... ../templates/admin/base_site.html Which contains ... {% extends "base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %} {% block branding %} {% trans 'Mysite administration' %} {% endblock %} ... and which turns Django Admin into Mysite admin. However, the "base.html" which it extends is actually in ../templates If I wanted Mysite base_site.html to extend the real Django base.html I would have to put ... {% extends "admin/base.html" %} HTH Mike That's exactly the path that my directories show, including my idiosyncratic upper case letters. I did find the file that my poll app is referencing. Turns out it was in my '/usr/local/lib/python2.6... path instead of my home directory. So when I modified THAT file, it used my changes. However, that still doesn't help, as it's not using the file that I copied to my local directory. I suppose I can play with a few more directories and see what happens... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New User Stuck on Tutorial Part 2
Thank you, Mike. That DID work! So, if I have a directory that contains the /admin/base_site.html, all I have to do is specify the containing directory. I'll need to study the actual string you used a little more closely once I get more familiar with the concepts. I can see how that would give you some added flexibility, but I'm not quite grokking the details yet. Still, at least I can continue the tutorial without that "mired in the mud" feeling. Thank you very much!!! On 05/10/2010 11:04 PM, Mike Dewhirst wrote: On 11/05/2010 3:42pm, Old Davy wrote: On 05/10/2010 08:18 PM, Shawn Milochik wrote: Exactly what directory is your copied template in? It's most likely not in the right place. Ensure that you have a template dir that your settings knows about, and that template dir has a subdirectory called 'admin' where that file is placed. Shawn That would make the most sense, and that would be my working assumption. But I can't for the life of me see where the disconnect is. this is the string that's in the TEMPLATE_DIRS section of my settings.py file: "/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS This is mine ... # if templates are not found here look in app_name/templates TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),) This puts my templates directory in the same dir as my settings.py file. Inside it I have a sub-dir for each application for which I want templates. For example, in one of them I have ... ../templates/admin/base_site.html Which contains ... {% extends "base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %} {% block branding %} {% trans 'Mysite administration' %} {% endblock %} ... and which turns Django Admin into Mysite admin. However, the "base.html" which it extends is actually in ../templates If I wanted Mysite base_site.html to extend the real Django base.html I would have to put ... {% extends "admin/base.html" %} HTH Mike That's exactly the path that my directories show, including my idiosyncratic upper case letters. I did find the file that my poll app is referencing. Turns out it was in my '/usr/local/lib/python2.6... path instead of my home directory. So when I modified THAT file, it used my changes. However, that still doesn't help, as it's not using the file that I copied to my local directory. I suppose I can play with a few more directories and see what happens... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
accessing the data value of a form in the html
hey there, I'm trying to access the data value of the form in HTML, but can't seem to figure out how to do this? (if it's possible?) I'm not interested in have the form out build the widget with the HTML ... i just want to show it's value, but build the HTML myself ... I'd still like to use the form for validation purposes. Thx ahead of time! Example: class UserForm(forms.Form): username = forms.CharField(label='Username', widget=forms.TextInput()) CODE: ctx['form'] = UserFBForm(initial={ 'username' : 'Joe User'}) return render_to_response('user.html', ctx) 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New User Stuck on Tutorial Part 2
On 11/05/2010 3:42pm, Old Davy wrote: On 05/10/2010 08:18 PM, Shawn Milochik wrote: Exactly what directory is your copied template in? It's most likely not in the right place. Ensure that you have a template dir that your settings knows about, and that template dir has a subdirectory called 'admin' where that file is placed. Shawn That would make the most sense, and that would be my working assumption. But I can't for the life of me see where the disconnect is. this is the string that's in the TEMPLATE_DIRS section of my settings.py file: "/home/llanitedave/Development/djangoProjects/django1.1Training/mysite/admin/base_site.html" You want a directory rather than a file (base_site.html) for TEMPLATE_DIRS This is mine ... # if templates are not found here look in app_name/templates TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates').replace('\\','/'),) This puts my templates directory in the same dir as my settings.py file. Inside it I have a sub-dir for each application for which I want templates. For example, in one of them I have ... ../templates/admin/base_site.html Which contains ... {% extends "base.html" %} {% load i18n %} {% block title %}{{ title }} | {% trans 'Mysite site admin' %}{% endblock %} {% block branding %} {% trans 'Mysite administration' %} {% endblock %} ... and which turns Django Admin into Mysite admin. However, the "base.html" which it extends is actually in ../templates If I wanted Mysite base_site.html to extend the real Django base.html I would have to put ... {% extends "admin/base.html" %} HTH Mike That's exactly the path that my directories show, including my idiosyncratic upper case letters. I did find the file that my poll app is referencing. Turns out it was in my '/usr/local/lib/python2.6... path instead of my home directory. So when I modified THAT file, it used my changes. However, that still doesn't help, as it's not using the file that I copied to my local directory. I suppose I can play with a few more directories and see what happens... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.