[mezzanine-users] Re: HomePage with contact form
Hello! I created small contact form on Home page by may be wrong, but quite simple way - without programming at all 1) Create regular mezzanine form in admin with URL contact-form, 2) Open form on site and look for fields names, 3) Hardcode form fields in index.html template using generated fields names and action=/contact-form/ (and don't forget {% csrf_token %} ) works fine for me! воскресенье, 18 мая 2014 г., 15:43:34 UTC+3 пользователь bob hosk написал: I've made a custom HomePage model, so I can edit the home page content (headers etc) from the admin easily. I'm trying to add a 'Contact us' form to the bottom of this page. In my 'myproject/mytheme' dir I have 'page_processors.py' containing from django import forms from django.http import HttpResponseRedirect from mezzanine.pages.page_processors import processor_for from .models import HomePage class ContactForm(forms.Form): subject = forms.CharField(max_length=100, initial='The subject...', required=True) message = forms.CharField(max_length= 5000, widget=forms.Textarea, initial='Hello, ', required=True) sender = forms.EmailField(initial='Your e-mail...') rchoices= ( ('WORK','Hire Me'), ('PROB','Site problems'), ('OTH', 'Other'), ) regarding = ChoiceField(widget=forms.Select(), choices=rchoices, blank_choice='Regarding?', initial='blank_choice') @processor_for(HomePage) def contact_form(request, page): form = ContactForm() if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # All validation rules pass subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] recipients = ['m...@me.com javascript:'] print message if cc_myself: recipients.append(sender) from django.core.mail import send_mail send_mail(subject, message, sender, recipients) redirect = request.path + ?submitted=true return HttpResponseRedirect(redirect) # Redirect after POST return {'form': form} As for the template for the custom home page, it {% extends pages/page.html %}, and at the bottom of the block I have {{ block.super }} {% if request.GET.sent %} {% editable page.form.response %} {{ page.form.response|richtext_filters|safe }} {% endeditable %} {% else %} {% with page.form as page_form %} {% editable page_form.content %} {{ page_form.content|richtext_filters|safe }} {% endeditable %} {% endwith %} {% errors_for form %} form class=mezzanine-form method=post{% if form.is_multipart %} enctype=multipart/form-data{% endif %} {% fields_for form %} div class=form-actions input class=btn btn-primary btn-lg type=submit value={{ page.form.button_text }} /div /form {% endif %} which I copied from 'mezzanine/forms/templates/pages/form.html' mostly. This gives a variable not found error when the homepage is loaded. If instead I did {% fields_for page.form %} then I don't get an error but nor do the fields appear to be rendered. How do I get this to work? -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Re: HomePage with contact form
Isn’t it even simpler to just {% extends page/form.html %} in index.html ? Le mardi 20 mai 2014 09:24:44 UTC+2, aleksiy a écrit : Hello! I created small contact form on Home page by may be wrong, but quite simple way - without programming at all 1) Create regular mezzanine form in admin with URL contact-form, 2) Open form on site and look for fields names, 3) Hardcode form fields in index.html template using generated fields names and action=/contact-form/ (and don't forget {% csrf_token %} ) works fine for me! воскресенье, 18 мая 2014 г., 15:43:34 UTC+3 пользователь bob hosk написал: I've made a custom HomePage model, so I can edit the home page content (headers etc) from the admin easily. I'm trying to add a 'Contact us' form to the bottom of this page. In my 'myproject/mytheme' dir I have 'page_processors.py' containing from django import forms from django.http import HttpResponseRedirect from mezzanine.pages.page_processors import processor_for from .models import HomePage class ContactForm(forms.Form): subject = forms.CharField(max_length=100, initial='The subject...', required=True) message = forms.CharField(max_length= 5000, widget=forms.Textarea, initial='Hello, ', required=True) sender = forms.EmailField(initial='Your e-mail...') rchoices= ( ('WORK','Hire Me'), ('PROB','Site problems'), ('OTH', 'Other'), ) regarding = ChoiceField(widget=forms.Select(), choices=rchoices, blank_choice='Regarding?', initial='blank_choice') @processor_for(HomePage) def contact_form(request, page): form = ContactForm() if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # All validation rules pass subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] recipients = ['m...@me.com'] print message if cc_myself: recipients.append(sender) from django.core.mail import send_mail send_mail(subject, message, sender, recipients) redirect = request.path + ?submitted=true return HttpResponseRedirect(redirect) # Redirect after POST return {'form': form} As for the template for the custom home page, it {% extends pages/page.html %}, and at the bottom of the block I have {{ block.super }} {% if request.GET.sent %} {% editable page.form.response %} {{ page.form.response|richtext_filters|safe }} {% endeditable %} {% else %} {% with page.form as page_form %} {% editable page_form.content %} {{ page_form.content|richtext_filters|safe }} {% endeditable %} {% endwith %} {% errors_for form %} form class=mezzanine-form method=post{% if form.is_multipart %} enctype=multipart/form-data{% endif %} {% fields_for form %} div class=form-actions input class=btn btn-primary btn-lg type=submit value={{ page.form.button_text }} /div /form {% endif %} which I copied from 'mezzanine/forms/templates/pages/form.html' mostly. This gives a variable not found error when the homepage is loaded. If instead I did {% fields_for page.form %} then I don't get an error but nor do the fields appear to be rendered. How do I get this to work? -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Re: modeltranslations - round 2
I’m not sure what you’re implying about toggling the translation fields. If it is about shrinking every translation field into a single one with tabs for each language, go ahead. I know that django-modeltranslation is supposed to allow that but I never had it working. If it is about adding translation fields for conf.Setting that need them (instead of the patchy note that I added lately), I plan to do it this weekend. As regard to the tests, at first I thought that it wasn’t necessary since django-modeltranslation has its own test coverage. But adding a test for each of the 4 items that were corrected plus another one to check if the TRANSLATED flag is correctly set is a good start. Le mardi 20 mai 2014 03:10:07 UTC+2, Eduardo Rivas a écrit : Hey Mathias, a couple of points here. First, do you plan on working on the admin controls for toggling the different translations fields? I'm asking because I'll have some free time in the coming weeks, but I don't want to jump into it if you're planning on doing it yourself. Secondly, I wanted to share with you that recently an effort has started to improve Mezzanine's test coverage. It'd be great if you could write some tests for the features you've contributed; but if you're short on time, just coming up with a list of pending tests for model translation will be of great help. You can share it with me or Steve and they'll be added to the task list. Thanks a lot! 2014-05-19 10:04 GMT-06:00 Mathias Ettinger mathias@gmail.comjavascript: : I read a bit on ugettext and ugettext_lazy and I agree that we should not move everything to plain ugettext. Using ugettext for the default value seems perfectly acceptable though. Since pregenerated content into the database is populated using the default language translation, it is exactly the same behavior. And django-modeltranslation will copy value based on that translation anyway. (./manage.py update_translation_fields) I found the time to make a last change to the settings admin page. It’s far from perfect, I have an idea on how to make it more like pages with every fields exposed but not much time for that. And at least it’s better than nothing. -- You received this message because you are subscribed to a topic in the Google Groups Mezzanine Users group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/VXVfCU8OFGk/unsubscribe . To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] upgrading from 1.4.6 to 3.1.6 south disappears
On Tuesday, May 13, 2014 6:55:44 AM UTC+2, Stephen McDonald wrote: Nice work tracking that down. The error you're getting looks like a missing library (called future, that link you found is misleading) - how have you installed the latest Mezzanine version? It should automatically install the required dependencies when installing via pip - you can see the future lib references here in the setup: https://github.com/stephenmcd/mezzanine/blob/master/setup.py#L60 http://jupo.org Just to follow up on this. It's all resolved now after I upgraded with pip. I was trying to run it off a git checkout for testing the upgrade before I installed it system wide. Not wise. Thanks for your help! -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Mezzanine under url prefix
No problem, I appreciate all your help. This is a weird one...because basically I am unable to add/edit pages when I have the prefix enabled. I've followed the directions outlined in urls.py - and everything else seems to be working as expected. Scott On Tuesday, May 20, 2014 6:47:10 AM UTC-7, Josh Cartmell wrote: Hey Scott, sorry but I honestly have no idea. I've never run Mezzanine under a different prefix. I have moved the admin to a prefix before which is why I knew that one. I would just dig into the Mezzanine URL's and see if it looks like something is off with the admin keywords submit. On Mon, May 19, 2014 at 6:39 PM, Scott Diehl mr.d...@gmail.comjavascript: wrote: Hey Josh, The prefix ('home') is working for all my page URLs and admin dashboard. However, I've found a couple errors (I think they are related) - When creating a new page, or editing a page, the save button doesn't do anything - I can see it is throwing a 404 in the console. If I remove the prefix, this works again... POST http://127.0.0.1:8000/home/admin_keywords_submit/ 404 (NOT FOUND) - The password_reset link on login page isn't working - if I remove the prefix it works. Any ideas? I'm wondering if there is a problem with how my template files are structured maybe? thanks, Scott On Friday, May 16, 2014 6:41:42 AM UTC-7, Josh Cartmell wrote: Hey Scott, I could be wrong, but I think you could do that by opening your project's urls.py and just changing the url that the admin is registered under. Currently you should have something like: (^admin/, include(admin.site.urls)), You could change it to: (^whatever-prefix/admin/, include(admin.site.urls)), On Thu, May 15, 2014 at 8:12 PM, Scott Diehl mr.d...@gmail.com wrote: I have a question in regards to this topic as well. I need to move our website under a site prefix (long story) - I have defined the site prefix in settings.py and have made the necessary changes in urls.py as well. The pages of the site are all working under the prefix. However, is there a way to also move admin portion of mezzanine behind the prefix as well? Is it just a matter of moving things around in the template files? thanks, Scott On Thursday, February 14, 2013 5:53:33 PM UTC-8, Stephen McDonald wrote: Should generally work. On Fri, Feb 15, 2013 at 12:06 PM, Eduardo Rivas jeriva...@gmail.comwrote: Hello, I'm in need of deploying a Mezzanine site under a URL prefix, let's say example.com/somepage. The domain connects to a server already running Wordpress, and Mezzanine most only live in this subpage. I think the question goes beyond the scope of this group, but I'm hoping someone else has already done something like this: - The domain is not owned by me, and I don't have control over it. Is it possible for the managers of the other server to redirect example.com/somepage to the Django instance in my server, preserving the url? They should be able to configure the web server to proxy to the django app - Is Mezzanine ready to run this way? Is it as simple as defining SITE_PREFIX? That's the intention. Thanks in advance! -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Stephen McDonald http://jupo.org -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Re: HomePage with contact form
Hi many thanks for all the different approaches here. In the end I did return {'contact_form': form} in my page processor, then {% fields_for contact_form %} in the template and all worked. It seems that the name 'form' must be passed to template by something else that was overriding it. -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Re: HomePage with contact form
Hi many thanks for all the different approaches here. In the end I did return {'contact_form': form} in my page processor, then {% fields_for contact_form %} in the template and all worked. It seems that the name 'form' must be passed to template by something else that was overriding it. On Sunday, 18 May 2014 14:43:34 UTC+2, bob hosk wrote: I've made a custom HomePage model, so I can edit the home page content (headers etc) from the admin easily. I'm trying to add a 'Contact us' form to the bottom of this page. In my 'myproject/mytheme' dir I have 'page_processors.py' containing from django import forms from django.http import HttpResponseRedirect from mezzanine.pages.page_processors import processor_for from .models import HomePage class ContactForm(forms.Form): subject = forms.CharField(max_length=100, initial='The subject...', required=True) message = forms.CharField(max_length= 5000, widget=forms.Textarea, initial='Hello, ', required=True) sender = forms.EmailField(initial='Your e-mail...') rchoices= ( ('WORK','Hire Me'), ('PROB','Site problems'), ('OTH', 'Other'), ) regarding = ChoiceField(widget=forms.Select(), choices=rchoices, blank_choice='Regarding?', initial='blank_choice') @processor_for(HomePage) def contact_form(request, page): form = ContactForm() if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # All validation rules pass subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] recipients = ['m...@me.com'] print message if cc_myself: recipients.append(sender) from django.core.mail import send_mail send_mail(subject, message, sender, recipients) redirect = request.path + ?submitted=true return HttpResponseRedirect(redirect) # Redirect after POST return {'form': form} As for the template for the custom home page, it {% extends pages/page.html %}, and at the bottom of the block I have {{ block.super }} {% if request.GET.sent %} {% editable page.form.response %} {{ page.form.response|richtext_filters|safe }} {% endeditable %} {% else %} {% with page.form as page_form %} {% editable page_form.content %} {{ page_form.content|richtext_filters|safe }} {% endeditable %} {% endwith %} {% errors_for form %} form class=mezzanine-form method=post{% if form.is_multipart %} enctype=multipart/form-data{% endif %} {% fields_for form %} div class=form-actions input class=btn btn-primary btn-lg type=submit value={{ page.form.button_text }} /div /form {% endif %} which I copied from 'mezzanine/forms/templates/pages/form.html' mostly. This gives a variable not found error when the homepage is loaded. If instead I did {% fields_for page.form %} then I don't get an error but nor do the fields appear to be rendered. How do I get this to work? -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Re: Amazon s3 storage backed, upload image to blog from admin HTTP 500 on demo site.
My settings.py is here http://paste.ubuntu.com/7494954/, and I think everything else is just the default mezzanine project install. local_settings.py is here http://paste.ubuntu.com/7494963/ -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Re: HomePage with contact form
But how would that deal with the actual business processing of the form? -- You received this message because you are subscribed to the Google Groups Mezzanine Users group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.