I am a Django newbie. I created an app which has a user login/registration page. Now I want to include CAPTCHA also in the registration page. Can somebody guide me how to implement this in Django as i am quite new to it. On googling I found there are many modules which do the function out of the box. If this is the way to go, then which application is a better choice? Also I found most of them were explained on the basis of using Django Forms. But I used simple HTML forms instead of Django forms. Any help would be appreciated.
Your question about which 3rd party solution is "better" is subjective, and stackoverflow doesn't generally like to answer subjective questions. Take some time and evaluate each in light of your needs.
You often don't need a fancy image captcha. Even a simple question like "what color is an orange?" will stop most spam bots. I posed a simple question on my registration form, asking the user to type the domain name of the site. Simple but very effective. You can also include an input box on the form, and hide it with CSS (display: none). If this input comes back to you filled out, chances are good a bot is trying to register.
It doesn't really matter that these 3rd party solutions are using Django forms, and you are using "simple HTML". In your registration view, you simply process request.POST. It doesn't matter how the form was generated.
I go for Google's reCAPTCHA, and its easy to integrate.
Here is a tutorial I wrote for integrating Google's reCAPTCHA in forms. Hope it helps.
You could write one yourself if you liked. All you are essentially doing is generating a number/word in your view, embedding it in the template in some robot-unfriendly way (an image for example) and then validating it when the form is posted back.
You can still use django-simple-captcha if you are using html forms instead of django forms.
Similar question: Easy-to-use django captcha or registration app with captcha?
Try: http://code.google.com/p/django-simple-captcha/
I followed the instructions at http://www.marcofucci.com/tumblelog/26/jul/2009/integrating-recaptcha-with-django/ to create a custom reCAPTCHA widget and field using the python client. You can then add it to your form with:
recaptcha = ReCaptchaField()
Related
I am making a website running wagtail as the CMS/backend and use Page for things that are actual web pages on the site. In addition to this I will need an Events section and I am unsure whether to make it as a Wagtail Page or Django models.Model.
The way I would like this to work for the user is to have an Events section in the admin panel using ModelAdmin so that the user can easily find and navigate to all Events, and, for those events to be displayed in various sections of the site - Home Page, Events Page, Article Page for example.
I think using Page for this and requiring the user to navigate to it (Home > Events Listing > Event Detail) each time is rather a waste of time and cumbersome as opposed to having it use ModelAdmin paired with Django models.Model and that being 1 or 2 clicks away.
Reading through my question it's obvious I am leaning towards using Django model for this, so my question is: what is the trade-off between the two? Is there a set use case for using one or the other? Would using one mean having more/less functionality over the other and what would those be?
Note: I know my question is almost identical to Guidelines for using Wagtail Pages or Django models? however it's more focused on ecommerce but most importantly it has no answer.
Use models.Model and register as a snippet because it will give you more flexibility.
As a user mentioned above, using a snippet is a great idea for what you're discussing. It's one click on the admin and they're in the event system. Then, you can just pass that model into the context for a page. Here's an example of doing this in Wagtail. See this example on adding snippets as streamfield if you wanted the customer to be able to place the events manually through the CMS.
I'm currently practicing making a blog in Django and I'd love to have WYSIWYG form field in Django but obviously it's not pre-built in Django and I know for a fact that I can create custom fields I just can't seem to find the right way to do it.
Any tutorials or tips would be appreciated. I don't want to use a package I want to do it myself just for the sake of learning.
Check out https://tutorial.djangogirls.org/
This tutorial will show you how to get the blogs on your admin panel
first of all i'd like to apologize if my problem seems to broad to answer but i'm really getting frustrated over this. so i'm a wordpress developer mainly (used to be a front end developer) and i'm getting into python django. but after taking many courses i can't seem to understand how to do the content management aspect of my project. so here is a rundown of my problem
in wordpress there is this concept of custom post meta where you can put fields that can change the heading of pages and fully customize the website so that the client won't need me every time he needs to change anything (CMS basically)
now i can't even begin to imagine how to go about doing something like that for django
i've tried putting a custom form on top of my list view in the admin page but that doesn't look so good and what if i need to customize a page that doesn't belong to a module with a list view
i've tried to make an app and call it page but then what about the stuff that is directly related to a module.
so my question is: how should i think about this since i don't want to go a long way in one direction just to discover that that is a poor way of doing things
also as a side note the site i'm creating is not that much bigger than a blog which i know i'd be better off doing in wordpress anyway but i thought it would be a good starting point to familiarize my self with django.
finally if you'd recommend any courses or maybe a tutorial i'd be more than grateful.
You're right, that is a very broad question. Here is a broad answer that I hope will help.
Django is a programming "framework" that can be used to develop new web-apps, including new CMS's. In my experience, the customizability of web-page titles in a new Django-app would involve using Django's html template language with template-tags and context-variables etc, as well as Python programming within the Django framework. For doing content management, you would basically have to program your own models & functions for that, along with whatever default or other database system (MySQL, PostgreSQL) you choose to install... There is a learning curve, but Python and Django are considered by some to be among the easiest language+frameworks to learn.
This tutorial playlist may help you. It helped me muddle thru Django in the beginning, and he has Python tutorials also.
Excuse me if I'm not very direct about what I'm talking about or need, I'm fairly new to django/python and am still in the process of understanding things.
I am creating a webapp with Django where a user will sign up, log in, create a new entry, save it, and view/edit it. Think of it as a personal diary that should be only accessible to the user who wrote it.
I've gotten pretty far in this and am using filtering in the ListView, but someone could easily use url manipulation to find other users entries.
Such that User A posts entry 4 at site.com/entry/4 and then user B is able to type that in and see the entry.
How can I go about restricting the url to only the user who posted it?
Thanks for any help, and again sorry if I'm not giving enough information or I'm not clear on what I am talking about!
I've been searching stack overflow and google for a solution for over an hour now, and I can't seem to find something that, in my opinion, should be easy to obtain (as it's a common use case).
I've checked this thread, and a few others, but I haven't been able to find a real, easy solution:
Django modelform: is inline adding related model possible?
Anyway, say I have a model with three related entities, two foreign keys and a many-to-many related class. Now, I have a ModelForm which displays these in comboboxes and lists, but what I need is that "+" button next to these elements (as seen in the admin interface).
I want the plus to take me to a new form, for that particular entity, allow me to submit the new information, create the database entry, take me back to my original form and have the newly added entity selected in the combobox. I'm really hoping the django ModelForm Meta class has an attribute that I can't seem to find which enables exactly this.
This isn't really a django question.
This has to do with presentation of a particular widget in an html document, and that is governed by either the HTML markup, CSS, or javascript.
Django is a server side application and is primarily responsible for creating a valid http response and receiving a valid http request (of course, there is a lot that happens in the interim and that is why django is so big) but it's not a "one toolkit to kill them all" app.
I think you want to look at bootstrap: http://getbootstrap.com/
Jquery UI: http://jqueryui.com/
Or some combination of the two.
You can also just mark up the document yourself with a stock img or something.
However, if you want to do it exactly how the admin does it, just go into django.contrib.admin and examin the code to figure out how the django developers did it. I believe they are just using Jquery UI and some manual markup to accomplish that.