Problems with jquery and accessing django template system
I have a url that I need to attach to link that is in a jquery section. It seem like the django template system is not getting the variable. For example: $.each(event,function(index,value){ var url = "{% url fiesta.views.detail "+ event[index].pk +" %}" $('#event_results').append( '' + event[index].fields.title + '' + event[index].fields.description + '' ) }); }, "json" ); --PROBLEM I need this url to be formatted like: {% url fiesta.view.detail 1 %} Where the number 1 would replace the event[index].pk However, it keeps printing the text: "event[index].pk" instead of the value. I have checked that the variable is returning values and it is returning values outside of django template blocks. I don't know, but it seems that the django template is reading the data before it is evaluated by jquery/javascript. How can I format the django template so that i can evaluate jquery variables. Thanks. regard, Kevin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problems with jquery and accessing django template system
Thanks Tom, but I have already tried that and it didn't work. On Wed, Nov 2, 2011 at 12:25 PM, Tom Evans wrote: > n Wed, Nov 2, 2011 at 5:13 PM, Kevin Miller wrote: >> I have a url that I need to attach to link that is in a jquery >> section. It seem like the django template system is not getting the >> variable. For example: >> >> $.each(event,function(index,value){ >> var url = "{% url fiesta.views.detail "+ >> event[index].pk +" %}" > > It gets the variable alright - the variable is the raw string "+ > event[index].pk + ". Template rendering happens before the javascript > runs. > > An option is to hardcode an id into the generated URL, and then replace it: > > var url = "{% url fiesta.views.detail 999 %}"; > url = url.replace('999', event[index].pk); > > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > 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-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.
Pinax or Straight Django
Dear all, I have been struggling between using Pinax or Straight django to develop my apps. I have never used Pinax, but was reading on it. I have already only developed one website in django although it is not yet launched. I would really like to hear the experiences of those who have used both. Are there really any benefits in using Pinax? NB: On a quick browse on google I realize that it was difficult to find good and up to date tutorials on Pinax. Thanks in advance for the replies. Kevin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
DateTime in Django (Help)
Dear all, I am new to django but is in the process of building my first website. I have been ok for a while as I am not new to programming in python. However, I have one problem that I cannot figure out the proper way to do it. I want to use ModelForm but have a DateTime Field. I can do it without using a ModelForm but I think using the ModelForm is the proper way to do it. Can someone show me a small example of using ModelForm with DateTime field? How can can the DateTime field me displayed in django templates? Thank you so much in advance. Kevin Miller -- 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: DateTime in Django (Help)
Thanks so much for your response. I have done all that and I have model forms working for other models. However, I keep getting validating errors with datetime, probably is how I am entering the data. I have also tried the SplitDateTimeWidget I am getting the same validation error. I have tried manually creating the form and it worked. I wonder what is the normally approach to DateTimeField in django templates. Is using the SplitDateTimeWidget the norm or should I use the AdminDateTimeWidget ? Thanks again. On Mon, May 9, 2011 at 11:11 AM, Kenny Meyer wrote: > On Mon, May 9, 2011 at 10:55 AM, Kevin Miller wrote: >> Dear all, >> >> I am new to django but is in the process of building my first website. I have >> been ok for a while as I am not new to programming in python. However, I have >> one problem that I cannot figure out the proper way to do it. I want to use >> ModelForm but have a DateTime Field. I can do it without using a ModelForm >> but >> I think using the ModelForm is the proper way to do it. > > What's the problem with the DateTimeField in a model? > >> Can someone show me a small example of using ModelForm with DateTime field? >> How can can the DateTime field me displayed in django templates? > > in your models.py: > > class Foo(models.Model): > datetime = models.DateTimeField() > > class FooForm(forms.ModelForm): > class Meta: > model = Foo > > > in your views.py: > > def bar(request): > form = FooForm() > return render_to_response("bar.html", {"form": form}) > > > in template bar.html: > > {{ foo }} > > > There's absolutely nothing special here :) . > > If you couldn't understand some of the code, then you should read the > documentation . > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ > > -- > 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. > > -- Kevin Miller Acting Data Controller Department of Computing UWI, Mona Kingston 7 -- 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.
problems using django-registration
Hi all, I am in the process of finishing up an app. However, I just cannot integrate django-registration and sessions properly. I can allow a user to register and also log in. But I am a bit confused in getting in to work with sessions. Eg. I want to get information based on the user that is logged in. I have look in the django book on session management and understand how to create sessions and destroy sessions..etc. So I believe I could do the entire process manually without email activation. But django-registration allows email activation which I also need. So I really want to use it but cannot integrate it with sessions. sessions do not event work with my templates. I tried to post a link only if the user is authenticated by doing this: {% if user.is_authenticated %} Log Out {% endif %} and it will not work, even after I log in the system using django-registration. I believe there is some broken link in my understanding of django-registration. Can anyone please tell me how to integrate session management with django-registration. Google did not help me that much. Thanks in advance. Kevin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: problems using django-registration
Oh silly me. I was not returning user in the HttpResponse. I don't why I assumed that it would be automatically available. Thanks all. On Mon, Jun 20, 2011 at 9:13 PM, Kenneth Gonsalves wrote: > On Mon, 2011-06-20 at 16:15 -0500, Kevin Miller wrote: >> Can anyone please tell me how to integrate session management with >> django-registration. Google did not help me that much. > > do you have this line in settings.py: > TEMPLATE_CONTEXT_PROCESSORS = ( > 'django.core.context_processors.request', > -- > regards > KG > http://lawgon.livejournal.com > Coimbatore LUG rox > http://ilugcbe.techstud.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-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. > > -- Kevin Miller Acting Data Controller Department of Computing UWI, Mona Kingston 7 -- 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: problems using django-registration
Oh silly me. I was not returning user in the HttpResponse. I don't why I assumed that it would be automatically available. Thanks all. 2011/6/20 没必要吧 : > Do you remember return user in HttpResponse? > > -- > 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. > > -- Kevin Miller Acting Data Controller Department of Computing UWI, Mona Kingston 7 -- 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.