When I post a comment with the django's comment framework, I have a hidden next value set in hopes that once the comment is posted, it will bring the user to view their own comment. The next field renders like this:
<input type="hidden" name="next" value="http://example.com/item/1#c23" />
However, when a comment is posted, django is adding a ?c=23 to the end of the url so the fully formed url that the user is redirected to becomes:
http://example.com/item/1#c23?c=23
In Firefox and Safari (brief testing) this prevents the page from moving down to the correct id=23 and just shows the very top of the page (I want it to show the just posted comment). Removing the ?c=23 fixes the problem (by hand) but I don't know how to tell Django to stop adding it.
Ideas?
Not a solution to your problem but just wanted to add that this is a bug in Django. It would be great if you could open a ticket for it.
For 1.1, it seems ticket 10585 took care of already existing query strings in the next value. That is, if next was http://example.com/item/1?a=1 then it became http://example.com/item/1?a=1?c=23 after a comment was posted. The code changes look pretty simple so you might even be able to provide a patch yourself.
Good luck!
Update February 27, 2011: Looks like ticket 13411 has a patch attached!
This jQuery line allows you to change the current URL:
$(this).attr("href", "NEW_URL");
Replace NEW_URL by the new URL. You can split http://example.com/item/1#c23?c=23 using the question mark and then use the first part of the array as the new URL.
Related
It's probably a stupid question.
I have a form on a custom list that I hade to custom design (the form for editing). But because of the law (GDPR) I can't let the users see the list after they save the form.
One part is sloved by them entering in the form from a page with a direct link to it. But the relinking is not.
This is the original part that I figured I have to change
<SharePoint:SaveButton runat="server" ControlMode="New" id="savebutton2"/>
I changed It to this
<SharePoint:SaveButton RedirectUrl="http://www.google.com" runat="server" ControlMode="New" id="savebutton2"/>
This also hellped but It just retuns me to the same empty form.
Can you tell me what I have to change to get it to actualy link it to the redirect link?
As I understand your question, you want to redirect users to another site after they've submitted a form.
What I have done in the past is modify the URL of the new form so that instead of the new item url being : http://mysite/org/hr/Lists/Exit/Item/newifs.aspx?List=b5b9e317%2D4366%2D4557%2D8d29%2Db5dedc71a75a&Source=http%3A%2F%2Fmysite%2Forg%2Fhr%2FLists%2FExit%2FCompleted%2Easpx&RootFolder=&Web=a86f3198%2D79a6%2D4e7f%2Daa26%2D448559533df8
I change the address after &Source in the above URL to the other site. So, it would now look like this:
http://mysite/org/hr/Lists/Exit/Item/newifs.aspx?List=b5b9e317%2D4366%2D4557%2D8d29%2Db5dedc71a75a&Source=http://www.google.com
What will happen, form will open, they'll save, and once the form closes, it will direct them to Google. I didn't need to modify the OOB save buttons - it's a good deal cleaner and quicker!
Hope this helps.
I am making a page that shows the list of post, which was in my blog, but the problem is, I just want to show 3 posts each page, if user clicks next, they can see the next 3 posts, or click previous to see the previous page. How can I do that? if the code is too long, you can just tell me how can I do that. I am thinking of using loop, but with previous function is a bad idea. Thanks for your reading and hope to see your reply soon
Use django pagination. If you use generic ListView then pagination will be done automatically by providing paginate_by parameter.
I want to create a simple registration form as one of the pages in my Joomla 2.5 website.
Every where on the internet, I see people asking me to use an extension like proforms, ckforms etc.. Most of the have price tags on them and the free ones do not have database and I don't really want a lot of functionality.
I just want the following code to work. So that I can pull the POST variable and insert them in a db.
<form method="post" action="mycreatedpage.php">
<input type="text"/>
<input type="submit">
</form>
Is this not possible in Joomla 2.5?
After a bit more searching, I realized that what I really needed was an ability to make PHP run inside the article. Thanks to a video.
Answer :
Install Sourcerer to enable PHP inside joomla articles
Create an article which take in the POST variable and insert into the database. This is the tricky part. What I did here was take the general PHP code which I would have written in register_do.php and insert it using the Sourcerer plugin.
Now create an menu Item which points to the above article. Save the menu item and copy the alias. This alias will be the action for the form.
From here on on, everything must work fine.
For more detailed instructions, watch the video
When you post a form, you have to have some code to handle the form input and what to do with it. So your options are to write a component to handle that form input or to use a form component that does it for you. If you write your own there is a lot to consider unless you want to open up gaping security holes in your website.
There are plenty of free forms components available. If you want free, I would recommend Chronoforms, if you don't mind paying small fee then RS Forms.
I'm using django 1.1. the docs
http://docs.djangoproject.com/en/1.1/topics/auth/#topics-auth
on the is_active flag it says
This doesn’t control whether or not
the user can log in. Nothing in the
authentication path checks the
is_active flag, so if you want to
reject a login based on is_active
being False, it is up to you to check
that in your own login view. However,
permission checking using the methods
like has_perm() does check this flag
and will always return False for
inactive users.
I'm using django-registration (latest 0.8 alpha) and using all the default backends. The entire premise of django-registration is based on the is_active flag. i.e. it only gets set after user has activated. However, I can see that when a user logs in it is using django.contrib.auth.views.login. i can see this from the code in auth_urls.py.
When a user registers, but hasn't activated yet, I want a message to be displayed that says something along the lines of "You have not activated your account"
Currently the default behaviour is the form's error message says, "user name and password do not match"
I'm also using the login decorator in my views
#login_required
My questions are:
EDIT: Thanks James and Henry. I don't think i've been very good at describing my questions. I've redone this.
the django documentation says that is_active is not used as a determinant when logging a user in. This is quite clearly NOT the case. Try it yourself. I can't figure out where this happens in the code. Does anybody know? As far as i can see, it doesn't happen in django-registration nor in django.contrib.auth.
In order to display the error message i've described above, what would be the best way for me to go about this? Please bear in mind i'm using django-registration and so a lot of the plumbing is done already. i'd rather not modify this or rewrite everything. if possible, i'm looking for an.... "elegant" solution.
Thanks in advance
with respect to Q1,
Thanks to everyone who pondered this question.
In the end i noticed some html code in the default template i hadn't noticed before.
{% if form.errors %}
<div class="error">
<p>Your username and password didn't match. Please try again.</p>
</div>
{% endif %}
Felt kind of stupid after seeing this. I had copied code from another project and just assumed the errors were being dynamically generated instead of being hardcoded.
so then i started investigating
forms.errors
and found
forms.non_field_errors
and trying to figure out how to style the output (because by default the stupid thing outputs it inside html ul tags) found this:
Django output form errors as table rows in {{ form.as_table }}
Thanks chands (as answer became obvious from his question)
One comment. Documentation on this (at least for 1.1) is terrible.
Why this isn't more explicit in offical django docs is beyond me. seems like a pretty basic thing one would want to do.
I think the issue is in the django-registration.
See the info on line 132 of https://bitbucket.org/ubernostrum/django-registration/src/tip/docs/quickstart.rst
It says that it will not allow non-active users to login.
UPDATE
You could write your own backend or use the simple backend and add a new property on your profile model called activated. This would be a fair amount of work.
As for where it is, I assume it is in django.contrib.auth.views.login. Not having spent much time looking through it i think you could fairly easily copy it and make your own. (if it is indeed the issue)
You would then need to replace it in the auth_urls.py file for the login url.
EDIT
I just went to docs 1.2 to check differences
http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.models.User.is_active
You will see that it says the form does test it. So either it always did but it wasn't decsribed properly or you've updated to 1.2 and forgotten/not known.
A company I'm looking at claims to have made the website for an airline and a furniture store using Django, but when I look at the sites, there is no indication what the underlying web technology is. How can you tell?
This is quite an old question, but I don't see any canonical answers. As the other answers have noted though, there's no sure-fire way to know, and if someone wanted to hide the fact that they're using Django, they can. That said, you can always do a little detective-work and determine with some confidence whether it uses Django or not. If that's your goal, here are some strong indicators you can look out for:
Admin Panel
First and foremost, check if the site has a /admin/ page. If it does, and it gives that familiar Django admin login page, you're 99% sure (unless someone went through a lot of trouble to make it look like Django).
Forms
There are a number of things you can look out for in forms:
Form fields with id attributes starting with id_
Check for a hidden field with the name csrfmiddlewaretoken
If the site has a formset, check for -TOTAL-FORMS and -DELETE hidden inputs.
Cookies
If the site uses the contrib.auth package for authentication, you will probably see a cookie called sessionid being set when you log in.
Forms will also probably set a cookie called csrftoken.
Trailing Slashes
Trailing slashes after URLs, and/or redirecting you to the page with a trailing slash if you try to go to one without it. This is Django's default behavior, and to my knowledge not extremely common in other frameworks. Note, though, that it can be easily deactivated in Django.
Error Pages
Failing all this, or still not being convinced, you can try to force error pages, and try to learn something from that. Go to an unmapped URL with a 404 page, and see if DEBUG still happens to be true (in which case you should probably notify the owner that they're not being very secure about their site).
You can try a few things, such as attempting to find error pages, and checking the default location of the administration panel that Django creates, but overall there's no way to determine what technologies a given site is using.
See also: https://stackoverflow.com/questions/563316/is-there-a-generic-way-to-see-what-is-a-website-running-on/563335#563335
Look for the csrf input box. This is present on any forms. But this can be turned off though not very recommended. Also if it's an old version of django this may not exist. But if it's there it's a strong indicator.
This is present on any page that have a post form. And it looks like this:
<input type='hidden' name='csrfmiddlewaretoken' value='3b3975ab79cec7ac3a2b9adaccff7572' />
Navigate to a page with a formset, and check if there are *-TOTAL_FORMS or *-DELETE hidden inputs.
That doesn't prove that they are using Django, but might be a clue that they are (with the mentioned model formsets).
Try to navigate to some 404 error page, or something of that sort. Chances are slim, but try to find a default django error page.
You can also try to login to www.website.com/admin and see if you get the default django admin page.
Other than that, if that didn't work, then you just can't.
There are no reliable indicators to my knowledge but you could check the /admin/ URL to see if you get the standard admin app or sometimes the feed-URLs use a common prefix compared to a common suffix (although this might not be an indicator at all but just a preference of the developers).
Trying to trigger a debug page (either via a 404 or using some broken input that might case an internal error) might also be a good way (although this acts more as a test of competency of the original developers and admin than anything else :-) )
Could you ask the airline and / or the furniture store? I'm guessing that you want to know if this company has good experience in django, I think it is reasonable to ask for references if you are considering working with them.
The other companies may be quite happy to discuss what technologies were used - some are and some aren't, but it's worth asking.