| Name | jheld |
|---|---|
| Email Address | jasonsheld@gmail.com |
| Website URL | http://sevenheroesbooks.blogspot.com/ |
| Avatar | |
| Posts | 4 |
| Board Signature | |
jheld | |
-
- 2011-06-11 11:13:32
- Re: Break out from the if loop - Django Template
- Board » Django » Templates
-
Ah, well you could keep a counter variable. Increment it, and check if you've gone over 0, if so, don't run the statements. In that logic, you'll still run through the loop, but you won't print anymore. Otherwise, handle this in the view so you won't have to do that continuous looping.jheld
-
- 2011-06-11 11:11:16
- Re: Break out from the if loop - Django Template
- Board » Django » Templates
-
Well, one reason I can think of is that your input is 0,1,0. 0 is False, so the longer message (the first case), will run twice.
First case is if != 1, therefore, false. So, it'll run TestCase Failed. Then because it is equal to 0, Failed.
Second run-through, it's a 1, so there will be no output.
Last run-through will mirror the first.
You're basically saying if this is not 1, print TestCase Failed, and then if it's 0, Failed. If you can only have 1's and 0's, then why not join those two if-statements into one?
The point is, you're nesting them unnecessarily, and you're asking why it's going through twice with your given input.
If you have 0,1,1, the fail prints would only run one each. It's as simple as that. I hope that helps.jheld
-
- 2011-06-01 16:44:48
- CSS through MEDIA_URL not working in another app
- Board » Django » Views
-
I have a writing site on localhost, and although the pages load correctly for writeapp, they won't for forumapp. All I've done is the usual extends syntax, but nothing. The page loads, but no accompanying css, though thankfully everything else works, such as user.username via django auth.
Any suggestions?
Ah. Nevermind. That was a silly question, and I've got the answer: make sure that if you EVER base your code off of someone else's that you make sure EVERYTHING relevant gets mapped to yours, like RequestContext in the views.
Solved!!
--- Last Edited by jheld at 2011-06-01 16:55:15 ---jheld
-
- 2011-06-01 14:09:15
- Re: Adding additional user information
- Board » Django Standard Library » Authentication
-
Clearly it has been over a year since you posted this question, but since I'm dealing in site creation and looking through this kind of stuff, I figured I would give my answer.
You could create two different types of UserProfiles . One that is a Teacher, and one that is a Student. If you have found the UserProfile code along stackoverflow, for instance, then you'll be just fine implementing this, I do believe. It wouldn't be very challenging at all.
Or, you could just create one UserProfile with a boolean value for what kind of user they are, and then the entire set of variables/fields. That isn't overly efficient, but it does stop you from creating too many UserProfile models. And then you can adjust your field requirements respectively.
There is probably another way, but these are things you might consider (or would have over a year ago).jheld


