Re: pub_date timezone
Hi erm I put that line in and still won't work. In my models.py file I have the following: from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) put_date = models.DateTimeField ('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes =models.IntegerField() After I entered import Poll the following would not run python manage.py shell When I removed it as seen above, the shell ran but the timezone issue still existed. Thanks again for your help Thanks for this advice. I did import On Thursday, October 25, 2012 1:36:39 PM UTC+1, Brendan Carroll wrote: > Hi all > I am new to Django and I'm having an issue with some code. I am trying to > get through the first tutorial from the Django site. > I have a file called polls/models.py and have created a class that > contains the following code > class Poll(models.Model): > question = models.CharField(max_length=200) > pub_date = models.DateTimeField('date published') > > The problem occurs when I go into the command prompt and enter the > following line > p = Poll(question = "Whats new? ", pub_date=timezone.now()) > The error is as follows: name Poll is not defined. > Appreciate any help guidance > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/vqONpt4ZL6cJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: pub_date timezone
Hi erm Went back over your comment and realised what you commented. After python manage.py I gget the python prompt>>> and then typed from polls.models import Poll, Choice then I typed: Poll.objects.all() and got the array brace [] returned. then I typed from django.utils import timezone then typed: p = Poll(question="Whats new?", pub_date=timezone.now()) This line will not run and tells me pub_date is an invalid argument. Thanks again in advance On Thursday, October 25, 2012 2:28:42 PM UTC+1, emr wrote: > Hi brendan, > > You have the import class before using, so > > from polls.models import Poll > > 2012/10/25 Brendan Carroll> >> Hi all >> I am new to Django and I'm having an issue with some code. I am trying to >> get through the first tutorial from the Django site. >> I have a file called polls/models.py and have created a class that >> contains the following code >> class Poll(models.Model): >> question = models.CharField(max_length=200) >> pub_date = models.DateTimeField('date published') >> >> The problem occurs when I go into the command prompt and enter the >> following line >> p = Poll(question = "Whats new? ", pub_date=timezone.now()) >> The error is as follows: name Poll is not defined. >> Appreciate any help guidance >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/dBbvVPL8BicJ. >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@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 view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/vZ3ZKc9753QJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Dynamically form modification - Is this possible?
I was hoping to use ajax and a customizable template with the additional fields that I'd added dynamically and then somehow update the form class with the info required to support form validation (however I'm not sure that this approach will work - I can get the initial display to work, but not the validation as the form class knows nothing about the additional data fields). This approach would eliminate the need to enable client/browser Javascript. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Dynamically form modification - Is this possible?
I'm still not clear on how/whether it is possible to MODIFY the form once it's been initially displayed - the __init__ method is invoked when the form is first created/constructed - what I want to do is rerender/redisplay the form with new fields after it's initial display -since the form need's to 'self modify'. Sorry for any confusion here, but I just want to understand/explore all the options. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Dynamically form modification - Is this possible?
Is there away to dynamically modify and validate a Django form AFTER it's been created and displayed. I have a form where I want to display and validate additional input fields based on the selection from a dropdown on the initial form. (I have found a few snippets that show dynamic form creation, but these require that the dynamic fields are known/defined prior to creating the form.) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Displaying a User Confirmation (Flash style) Message after a redirect - How?
I see that the an upcoming will include a new messaging framework to display custom user messages - I think this is designed to mimic ROR. See:http://docs.djangoproject.com/en/dev/ref/contrib/messages/ In the current release V1.0 or 1.1 what is the recommended approach? On a successful save I want to redirect the user to a new page, then display a save confirmation message that includes the ID of the new record. (I'm thinking of using a session object, but there appear to be some pros/cons.) Links to examples would also help. TIA BrendanC -- 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 pass context with a form?
Replying to my own message - problem solved - ignore previous posting! I forgot to include my variables in my response so expected values were not being passed - I was doing this: variables = RequestContext(request, { 'form': form, 'caller': caller, 'error': error }) return render_to_response('search.html') instead of: variables = RequestContext(request, { 'form': form, 'caller': caller, 'error': error }) return render_to_response('search.html', variables) Just another brain fart at my end. Sometimes I just can't see the wood for the trees! On Apr 12, 1:21 pm, BrendanC <bren...@gmail.com> wrote: > I have a reusable search form and want to display a different form > header based on where/how the search is called from (I get this from > the url). In the search template I'd like to test a variable to > determine which header to display. I need to somehow pass variable > from the view the template - something like this: > > form = SearchForm({'Retired' :'Retired Staff''}) > > then in the search template check the Retired variable : > > > {% if Retired %} > Search Retired Staff List. > {% endif %} > > > The generic search form class is" > class SearchForm(forms.Form): > > # Create a Search Form - set form header to value passed by > caller > > query = forms.CharField( > label=u'Search by Employee ID ', > widget=forms.TextInput(attrs={'size': 32}) > ) > > The catch here is that the variable is not a field on the form. So how > can Ito pass context info at form creation time? Is this possible? -- 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 pass context with a form?
I have a reusable search form and want to display a different form header based on where/how the search is called from (I get this from the url). In the search template I'd like to test a variable to determine which header to display. I need to somehow pass variable from the view the template - something like this: form = SearchForm({'Retired' :'Retired Staff''}) then in the search template check the Retired variable : {% if Retired %} Search Retired Staff List. {% endif %} The generic search form class is" class SearchForm(forms.Form): # Create a Search Form - set form header to value passed by caller query = forms.CharField( label=u'Search by Employee ID ', widget=forms.TextInput(attrs={'size': 32}) ) The catch here is that the variable is not a field on the form. So how can Ito pass context info at form creation time? Is this possible? -- 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.