Search Results

Search found 1619 results on 65 pages for 'humble student'.

Page 5/65 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Manditory read-only fields in django

    - by jamida
    I'm writing a test "grade book" application. The models.py file is shown below. class Student(models.Model): name = models.CharField(max_length=50) parent = models.CharField(max_length=50) def __unicode__(self): return self.name class Grade(models.Model): studentId = models.ForeignKey(Student) finalGrade = models.CharField(max_length=3) I'd like to be able to change the final grade for several students in a modelformset but for now I'm just trying one student at a time. I'm also trying to create a form for it that shows the student name as a field that can not be changed, the only thing that can be changed here is the finalGrade. So I used this trick to make the studentId read-only. class GradeROForm(ModelForm): studentId = forms.ModelChoiceField(queryset=Student.objects.all()) def __init__(self, *args, **kwargs): super(GradeROForm,self).__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance and instance.id: self.fields['studentId'].widget.attrs['disabled']='disabled' def clean_studentId(self): instance = getattr(self,'instance',None) if instance: return instance.studentId else: return self.cleaned_data.get('studentId',None) class Meta: model=Grade And here is my view: def modifyGrade(request,student): student = Student.objects.get(name=student) mygrade = Grade.objects.get(studentId=student) if request.method == "POST": myform = GradeROForm(data=request.POST, instance=mygrade) if myform.is_valid(): grade = myform.save() info = "successfully updated %s" % grade.studentId else: myform=GradeROForm(instance=mygrade) return render_to_response('grades/modifyGrade.html',locals()) This displays the form like I expect, but when I hit "submit" I get a form validation error for the student field telling me this field is required. I'm guessing that, since the field is "disabled", the value is not being reported in the POST and for reasons unknown to me the instance isn't being used in its place. I'm a new Django/Python programmer, but quite experienced in other languages. I can't believe I've stumbled upon such a difficult to solve problem in my first significant django app. I figure I must be missing something. Any ideas?

    Read the article

  • How does the recursion here work?

    - by David
    code 1: public static int fibonacci (int n){ if (n == 0 || n == 1) { return 1; } else { return fibonacci (n-1) + fibonacci (n-2); } } how can you use fibonacci if you haven't gotten done explaining what it is yet? I've been able to understand using recursion in other cases like this: code two: class two { public static void two (int n) { if (n>0) { System.out.println (n) ; two (n-1) ; } else { return ; } } public static void main (String[] arg) { two (12) ; } } In the case of code 2 though n will eventualy reach a point at which it doesnt satisfy n0 and the method will stop calling itself recursivly. in the case of code 2 though i don't see how it would be able to get itself from 1 if n=1 was the starting point to 2 and 3 and 5 and so on. Also i don't see how the line `return fibonacci (n-1) + fibonacci (n-2) would work since fibbonacci n-2 has to contain in some sense fibonacci n-1 in order to wrok but it isn't there yet. I know my question is worded poorly but looking at this is making my mind explode. the book i'm looking at says it will work. how does it work? `

    Read the article

  • Entity Relationship diagram - Composition

    - by GigaPr
    Hi, I am implementing a small database(university Project) and i am facing the following problem. I created a class diagram where i have a class Train {Id, Name, Details} And a class RollingStock which is than generalized in Locomotive and FreightWagon. A train is Composed by multiple RollingStock at a certain time(on different days the rolling stock will compose a different train). I represented the relationship train - rolling stock as a diamond filled (UML) but still I have a many to many relationship between the two tables. so i guess i have to create an additional table to solve the many to many relationship train_RollingStock. but how do i represent the Composition? Can i still use the filled diamond? If yes on which side? Thanks

    Read the article

  • What's wrong with this conditional?

    - by David
    I am trying to make a method that tests to see if 3 lengths can make a triangle. I think i'm making some kind of syntax error but i can't figure out what it is. Here is the relevant bit of code: (its in java) public static void trya (int a, int b, int c) { if (c>(a+b)) { System.out.println ("yes") ; } else { if (b>(a+c)) { System.out.println ("yes") ; } } else { if (a>(b+c)) { System.out.println ("yes") ; } } else { System.out.println ("no") ; } } this is the error message i get: tryangle.java:17: 'else' without 'if' else ^

    Read the article

  • In what programing language are the things i actualy care about writin? [closed]

    - by David
    To be more specific and less subjective: In what language are video games like Halo 3/COD 4/ mario cart written? Microsoft word for windows? for mac? The animation software used by big movie studios to make movies like toystory and monsters inc? The software that helps pilots control the F22 raptor? The software that watches the stock market? The software in the computer in my car? The software that makes the internet work? (this one is a bit vague, if more specificness is needed then google specifically) robots?

    Read the article

  • Why does does my stack overflow error occur after 518669 specifically?

    - by David
    I created a java program to count up toward infinity: class up { public static void up (int n) { System.out.println (n) ; up (n+1) ; } public static void main (String[] arg) { up (1) ; } } i didn't actually expect it to get there but the thing that i noticed that was a bit curious was that it stopped at the same number each time: 518669 what is the significance of this number? (or of this number +1 i suppose). (also as a bit of an aside question, I've been told that the way i format my code is bad [indentation and such] what am i doing that isn't desirable?)

    Read the article

  • How you would you describe the Observer pattern in beginner language?

    - by Sheldon
    Currently, my level of understanding is below all the coding examples on the web about the Observer Pattern. I understand it simply as being almost a subscription that updates all other events when a change is made that the delegate registers. However, I'm very unstable in my true comprehension of the benefits and uses. I've done some googling, but most are above my level of understanding. I'm trying to implement this pattern with my current homework assignment, and to truly make sense on my project need a better understanding of the pattern itself and perhaps an example to see what its use. I don't want to force this pattern into something just to submit, I need to understand the purpose and develop my methods accordingly so that it actually serves a good purpose. My text doesn't really go into it, just mentions it in one sentence. MSDN was hard for me to understand, as I'm a beginner on this, and it seems more of an advanced topic. How would you describe this Observer pattern and its uses in C# to a beginner? For an example, please keep code very simple so I can understand the purpose more than complex code snippets. I'm trying to use it effectively with some simple textbox string manipulations and using delegates for my assignment, so a pointer would help!

    Read the article

  • Compiler is able to find function without matching .h file is updated?

    - by Maxim Veksler
    Hello Friends, I'm writing a C University project and stumbled upon a compiler behavior which I don't understand. In this file http://code.google.com/p/openu-bsc-maximveksler/source/browse/trunk/20465/semester/tasks/maman14/alpha/maman14/assembler/phaseOne.c?r=112 I've added a call to function named freeAsmInstruction(). This function is defined in file named lineParser.c, yet I haven't updated the matching lineParser.h header file to include this function declaration. Why does this code compile? I would expect that gcc would fail to compile phaseOne.c until the correct lineParser.h is updated with the declaration of freeAsmInstruction(). I would appreciate an explanation. Thank you, Maxim

    Read the article

  • how to implement video and audio merger program ?

    - by egebilmuh
    Hi guys I want to make a program which takes video and audio and merges them. Video Type or audio type is not important for me. I just want to make so- called program. How can i make this ? does any library exist for this ? (I know there are many program about this topic but i want to learn how to implement such a program.) Help me please about this topic.

    Read the article

  • Execute javascript from link

    - by GigaPr
    Hi, i am just trying to create a link which execute some JavaScript in stead to redirect the user to a particular page I tried the following but it doesn t work <a href="#" onclick="javascript:location.replace('http://http://stackoverflow.com/questions/ask');">www.google.com</a><br /> <a href="javascript:location.replace('http://stackoverflow.com/questions/ask');">www.google.com</a> I am not trying to do anything illegal whit the redirect, just an exercise for a university module (Internet Security) Thanks

    Read the article

  • debugging scaffolding contingent upon degbugging boolean (java)

    - by David
    Recently i've found myself writing a lot of methods with what i can only think to call debugging scaffolding. Here's an example: public static void printArray (String[] array, boolean bug) { for (int i = 0; i<array.lenght; i++) { if (bug) System.out.print (i) ; //this line is what i'm calling the debugging scaffolding i guess. System.out.println(array[i]) ; } } in this method if i set bug to true, wherever its being called from maybe by some kind of user imput, then i get the special debugging text to let me know what index the string being printed as at just in case i needed to know for the sake of my debugging (pretend a state of affairs exists where its helpful). All of my questions more or less boil down to the question: is this a good idea? but with a tad bit more objectivity: Is this an effective way to test my methods and debug them? i mean effective in terms of efficiency and not messing up my code. Is it acceptable to leave the if (bug) stuff ; code in place after i've got my method up and working? (if a definition of "acceptability" is needed to make this question objective then use "is not a matter of programing controversy such as ommiting brackets in an if(boolean) with only one line after it, though if you've got something better go ahead and use your definition i won't mind) Is there a more effective way to accomplish the gole of making debugging easier than what i'm doing? Anything you know i mean to ask but that i have forgotten too (as much information as makes sense is appreciated).

    Read the article

  • Free Fall Question

    - by Makenshi
    ok im gonna try my best to explain my problem i have this program where u can select 5 balls when u select one you can take it with you while you have the mouse button pressed and its within the ball radius. The problem is that i need a way to make the ball go up when the user stop pressing the mouse button like he sent it to float in the air then make it fall down again i have one way to know the time,velocity and thus the acceleration but i dont know how to implement it... right now i have this void Circulo::caida(float velocidad,float tiempo) { if(this->posY >= 580) { this->posY = 580; this->vcaida = 0.0f; } else if(this->posY < 580) { //this->distancia=9.81f * 0.5f*tiempo*tiempo; this->vcaida += velocidad; this->posY += this->vcaida; } } with this like this it just falls and i cant make the effect i tried to explain... thank you i hope someone can help me .< oh yeah im calculating the time like this just in case it helps difX=(x> evento.motion.xrel)? x-evento.motion.xrel : evento.motion.xrel-x; difY=(y> evento.motion.yrel)? y-evento.motion.yrel : evento.motion.yrel-y; and im sending difY as the time variable

    Read the article

  • special debugging lines (java)

    - by David
    Recently i've found myself writing a lot of methods with what i can only think to call debugging scaffolding. Here's an example: public static void printArray (String[] array, boolean bug) { for (int i = 0; i<array.lenght; i++) { if (bug) System.out.print (i) ; //this line is what i'm calling the debugging scaffolding i guess. System.out.println(array[i]) ; } } in this method if i set bug to true, wherever its being called from maybe by some kind of user imput, then i get the special debugging text to let me know what index the string being printed as at just in case i needed to know for the sake of my debugging (pretend a state of affairs exists where its helpful). All of my questions more or less boil down to the question: is this a good idea? but with a tad bit more objectivity: Is this an effective way to test my methods and debug them? i mean effective in terms of efficiency and not messing up my code. Is it acceptable to leave the if (bug) stuff ; code in place after i've got my method up and working? (if a definition of "acceptability" is needed to make this question objective then use "is not a matter of programing controversy such as ommiting brackets in an if(boolean) with only one line after it, though if you've got something better go ahead and use your definition i won't mind) Is there a more effective way to accomplish the gole of making debugging easier than what i'm doing? Anything you know i mean to ask but that i have forgotten too (as much information as makes sense is appreciated).

    Read the article

  • What side project/research should be chosen to increase my Marketability

    - by CheesePls
    I am a Junior CS Major at a Javaschool and I find myself having an easy time and thought there may be some good project or a language to learn or research in this newfound free time. What would you recommend so as to increase my ability to find a good job(somewhere that allows for continuous learning and treats its programmers well)after college? My thoughts were learning Scheme, making a working Zelda-like game(the original), find some open source project to help with.

    Read the article

  • OO vs Simplicity when it comes to user interaction

    - by Oetzi
    Firstly, sorry if this question is rather vague but it's something I'd really like an answer to. As a project over summer while I have some downtime from Uni I am going to build a monopoly game. This question is more about the general idea of the problem however, rather than the specific task I'm trying to carry out. I decided to build this with a bottom up approach, creating just movement around a forty space board and then moving on to interaction with spaces. I realised that I was quite unsure of the best way of proceeding with this and I am torn between two design ideas: Giving every space its own object, all sub-classes of a Space object so the interaction can be defined by the space object itself. I could do this by implementing different land() methods for each type of space. Only giving the Properties and Utilities (as each property has unique features) objects and creating methods for dealing with the buying/renting etc in the main class of the program (or Board as I'm calling it). Spaces like go and super tax could be implemented by a small set of conditionals checking to see if player is on a special space. Option 1 is obviously the OO (and I feel the correct) way of doing things but I'd like to only have to handle user interaction from the programs main class. In other words, I don't want the space objects to be interacting with the player. Why? Errr. A lot of the coding I've done thus far has had this simplicity but I'm not sure if this is a pipe dream or not for larger projects. Should I really be handling user interaction in an entirely separate class? As you can see I am quite confused about this situation. Is there some way round this? And, does anyone have any advice on practical OO design that could help in general?

    Read the article

  • taking integer input in java

    - by ruchir patwa
    I am actually new to java programming and am finding it difficult to take integer input and storing it in variables...i would like it if someone could tell me how to do it or provide with an example like adding two numbers given by the user..

    Read the article

  • Casting problem cant convert from void to float C++

    - by Makenshi
    as i said i get this horrible error i dont really know what to do anymore float n= xAxis[i].Normalize(); thats where i get the error and i get it cuz normalize is a void function this is it void CVector::normalize() { float len=Magnitude(); this->x /= len; this->y /= len; } i need normalize to stay as void tho i tried normal casting like this float n= (float)xAxis[i].Normalize(); and it doesnt work also with static,dynamic cast,reinterpret,const cast and cant make it work any help would be really apreciated... thank you .<

    Read the article

  • In this program(Java) I'm trying to make a dice roller. How do I make it so it rolls a bunch of times and adds the rolls?

    - by Mac
    import java.util.Random; public class dice { private int times; private int roll; private int side; Random roller = new Random(); public void setTimes(int sides) { times = sides; } public void setSides(int die) { side = die; } public int getRoll() //this is where the "rolling" happens { int total = 0; int c = 0; while (c <= times) { c = c + 1; int rol = 0; roll = roller.nextInt(side) + 1; rol = rol + roll; total = rol; } return total; } } If you need the GUIWindow and the main, just ask

    Read the article

  • missing subscript c++

    - by Makenshi
    right now c++ is giving me this error: error C2087 'color' missing subscript first time i get this and i dont know what to do .< hope any1 can help me struct Color{ float r; float g; float b; };Color color[][]; and im using it here for(int i=0;i<cubes;i++) { color[i][0].r = fRand();color[i][0].g=fRand(.5);color[i][0].b=fRand(); ...etc

    Read the article

  • Beginner SQL question(s)

    - by unit
    I am two months in to an intro sql course, it's late at night, and I am drawing a blank. I have two tables, one customers, and one orders. I have to increase any customers credit limit by twenty five percent for all customers who have made two or more orders in which each order is more than the amount of 250.00. I get how to UPDATE CreditLimit * 1.25 and Cust with an order 250, but how the hell do I get it to check if they have made two orders over 250? Second question, we are just starting to take subqueries, and I am having a difficult time getting it into my skull. Another question posed by the prof of our class is to increase the credit limit of a customer who has an order that exceeds their credit limit. (Credit limit is on a customers table, order and amount are on an orders table). I then take that customer and UPDATE his CreditLimit +1000. Thanks for any help.

    Read the article

  • Java Dynamic Binding

    - by Chris Okyen
    I am having trouble understanding the OOP Polymorphic principl of Dynamic Binding ( Late Binding ) in Java. I looked for question pertaining to java, and wasn't sure if a overall answer to how dynamic binding works would pertain to Java Dynamic Binding, I wrote this question. Given: class Person { private String name; Person(intitialName) { name = initialName; } // irrelevant methods is here. // Overides Objects method public void writeOutput() { println(name); } } class Student extends Person { private int studentNumber; Student(String intitialName, int initialStudentNumber) { super(intitialName); studentNumber = initialStudentNumber; } // irrellevant methods here... // overides Person, Student and Objects method public void writeOutput() { super.writeOutput(); println(studentNumber); } } class Undergaraduate extends Student { private int level; Undergraduate(String intitialName, int initialStudentNumber,int initialLevel) { super(intitialName,initialStudentNumber); level = initialLevel; } // irrelevant methods is here. // overides Person, Student and Objects method public void writeOutput() { super.writeOutput(); println(level); } } I am wondering. if I had an array called person declared to contain objects of type Person: Person[] people = new Person[2]; person[0] = new Undergraduate("Cotty, Manny",4910,1); person[1] = new Student("DeBanque, Robin", 8812); Given that person[] is declared to be of type Person, you would expect, for example, in the third line where person[0] is initialized to a new Undergraduate object,to only gain the instance variable from Person and Persons Methods since doesn't the assignment to a new Undergraduate to it's ancestor denote the Undergraduate object to access Person - it's Ancestors, methods and isntance variables... Thus ...with the following code I would expect person[0].writeOutput(); // calls Undergraduate::writeOutput() person[1].writeOutput(); // calls Student::writeOutput() person[0] to not have Undergraduate's writeOutput() overidden method, nor have person[1] to have Student's overidden method - writeOutput(). If I had Person mikeJones = new Student("Who?,MikeJones",44,4); mikeJones.writeOutput(); The Person::writeOutput() method would be called. Why is this not so? Does it have to do with something I don't understand about relating to arrays? Does the declaration Person[] people = new Person[2] not bind the method like the previous code would?

    Read the article

  • As a young student aspiring to have a career as a programmer, how should I feel about open source software?

    - by Matt
    Every once in a while on some technology websites a headline like this will pop up: http://www.osor.eu/news/nl-moving-to-open-source-would-save-government-one-to-four-billion My initial thought about government and organizations moving to open source software is that tons of programmers would lose their jobs and the industry would shrink. At the same time the proliferation and use of open source software seems to be greatly encouraged in many programming communities. Is my thinking that the full embrace of open source software everywhere will hurt the software industry a misconception? If it is not, then why do so many programmers love open source software?

    Read the article

  • I'm a CS student, and honestly I don't understand Knuth's books..

    - by Raymond Ho
    I stumbled this quote from Bill Gates: "You should definitely send me a resume if you can read the whole thing." He was talking about The Art of Programming books.. So I was pretty curious and want to read it all but honestly, I don't understand it at all.. I'm really not that highly intellectual being.. So this should be the reason why I can't understand it, but I am eager to learn.. I'm currently reading volume 1 about fundamental algo.. So is there any books out there that are friendly to novice/slow people like me? So I can build up myself and hopefully in the future I can read Knuth's book at ease..

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >