Search Results

Search found 1021 results on 41 pages for 'has and belongs to many'.

Page 22/41 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • django username in url, instead of id

    - by dana
    Hello, in a mini virtual community, i have a profile_view function, so that i can view the profile of any registered user. The profile view function has as a parameter the id of the user wich the profile belongs to, so that when i want to access the profile of user 2 for example, i call it like that: http://127.0.0.1:8000/accounts/profile_view/2/ My problem is that i would like to have the username in the url, and NOT the id. I try to modify my code as follows, but it doesn't work still. Here is my code: view: def profile_view(request, user): u = User.objects.get(pk=user) up = UserProfile.objects.get(created_by = u) cv = UserProfile.objects.filter(created_by = User.objects.get(pk=user)) blog = New.objects.filter(created_by = u) replies = Reply.objects.filter(reply_to = blog) vote = Vote.objects.filter(voted=blog) following = Relations.objects.filter(initiated_by = u) follower = Relations.objects.filter(follow = u) return render_to_response('profile/publicProfile.html', { 'vote': vote, 'u':u, 'up':up, 'cv': cv, 'ing': following.order_by('-date_initiated'), 'er': follower.order_by('-date_follow'), 'list':blog.order_by('-date'), 'replies':replies }, context_instance=RequestContext(request)) and my url: urlpatterns = patterns('', url(r'^profile_view/(?P<user>\d+)/$', profile_view, name='profile_view'), thanks in advance!

    Read the article

  • About Network Address Translation (NAT)?

    - by Rudi
    Just curious about a particular scenario of NAT. Let's suppose we have 4 computers sharing a global IP address under the NAT. I understand that the NAT box keeps an internal record to know which computer to forward requests to. But let's say on computer #2 I'm trying to download a file. And let's say on computer #1, #3, and #4, I'm just browsing the web normally. When the browser initiates a TCP connection to get that file, how does it know which computer to give it to? I mean like, each of the four computers is using port 80 to browse the web right? How does the NAT's record distinguish which "port 80" belongs to which computer?

    Read the article

  • Operation can only be performed on cells that belong to a DataGridView control

    - by The Demigeek
    The following code throws an InvalidOperationException with the above message and I don't understand why. My code calls the following method when the user may have made changes to the datagridview's underlying data source. The goal is to update the display with any changed data, and preserve the sort column and order. private void ReloadDataGridBindingListFromDatabase() { DataGridView dgv = myDataGridViewControl; DataGridViewColumn sortedColumn = dgv.SortedColumn; SortOrder sortOrder = dgv.SortOrder; //do stuff here to refresh dgv.DataSource if (sortedColumn != null) { //this line throws an exception sortedColumn.HeaderCell.SortGlyphDirection = sortOrder; } //etc. } Clearly, sortedColumn.HeaderCell is a cell that belongs to a DataGridView control. So why am I getting this exception? Many thanks for your input.

    Read the article

  • How to obtain the root of a tree without parsing the entire file?

    - by Matt.
    I'm making an xml parser to parse xml reports from different tools, and each tool generates different reports with different tags. For example: Arachni generates an xml report with <arachni_report></arachni_report> as tree root tag. nmap generates an xml report with <nmaprun></nmaprun> as tree root tag. I'm trying not to parse the entire file unless it's a valid report from any of the tools I want. First thing I thought to use was ElementTree, parse the entire xml file (supposing it contains valid xml), and then check based on the tree root if the report belongs to Arachni or nmap. I'm currently using cElementTree, and as far as I know getroot() is not an option here, but my goal is to make this parser to operate with recognized files only, without parsing unnecessary files. By the way, I'm Still learning about xml parsing, thanks in advance.

    Read the article

  • Accessing Textboxes in Repeater Control

    - by CccTrash
    All the ways I can think to do this seem very hackish. What is the right way to do this, or at least most common? I am retrieving a set of images from a LINQ-to-SQL query and databinding it and some other data to a repeater. I need to add a textbox to each item in the repeater that will let the user change the title of each image, very similar to Flickr. How do I access the textboxes in the repeater control and know which image that textbox belongs to? Here is what the repeater control would look like, with a submit button which would update all the image rows in Linq-to-SQL:

    Read the article

  • How precise is the internal clock of a modern PC?

    - by mafutrct
    I know that 10 years ago, typical clock precision equaled a system-tick, which was in the range of 10-30ms. Over the past years, precision was increased in multiple steps. Nowadays, there are ways to measure time intervals in actual nanoseconds. However, usual frameworks still return time with a precision of only around 15ms. My question is, which steps did increase the precision, how is it possible to measure in nanoseconds, and why are we still often getting less-than-microsecond precision (for instance in .NET). (Disclaimer: It strikes me as odd that this was not asked before, so I guess I missed this question when I searched. Please close and point me to the question in that case, thanks. I believe this belongs on SO and not on any other SOFU site. I understand the difference between precision and accuracy.)

    Read the article

  • sql query question / count

    - by scheibenkleister
    Hi, I have houses that belongs to streets. A user can buy several houses. How do I find out, if the user owns an entire street? street table with columns (id/name) house table with columns (id/street_id [foreign key] owner table with columns (id/house_id/user_id) [join table with foreign keys] So far, I'm using count which returns the result: select count(*), street_id from owner left join house on owner.house_id = house.id group by street_id where user_id = 1 count(*) | street_id 3 | 1 2 | 2 A more general count: select count(*) from house group by street_id returns: count(*) | street_id 3 | 1 3 | 2 How can I find out, that user 1 owns the entire street 1 but not street 2? Thanks.

    Read the article

  • How to hide parent tabbar when pushing controller in navigationController

    - by Yannis
    Hi all, I have an application with a tab bar controller and each view contains a navigation controller. My MainWindow looks as follows: Everything works fine as it is but I noticed a problem when pushing a details view to the navigation controller. In the didSelectRowAtIndexPath for a tableviewcontroller that belongs to the tab bar controller (the one called Latest in the image) I am doing this: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ArticleViewController *articleController = [[ArticleViewController alloc] initWithNibName:@"ArticleView" bundle:nil]; [self.navigationController pushViewController:articleController animated:YES]; [articleController release]; articleController = nil; } The ArticleViewController has its own tabbar because it needs to display different things. The problem is that when I push the ArticleViewController into the navigationController I see both tabbars at the bottom of the view. Is there any way I can solve this problem? Thanks in advance

    Read the article

  • String Constant Pool memory sector and garbage collection

    - by WickeD
    I read this question on the site How is the java memory pool divided? and i was wondering to which of these sectors does the "String Constant Pool" belongs? And also does the String literals in the pool ever get GCed? The intern() method returns the base link of the String literal from the pool. If the pool does gets GCed then wouldn't it be counter-productive to the idea of the string pool? New String literals would again be created nullifying the GC. (It is assuming that only a specific set of literals exist in the pool, they never go obsolete and sooner or later they will be needed again)

    Read the article

  • Problem with ASP.NET MVC DropDownList not displaying selected value

    - by Jova
    I have an aspx page which allows me to edit articles. Among things I can edit is which category the article belongs to. The category is chosen through a DropDownList as shown here, <%= Html.DropDownList("categoryID", (IEnumerable<SelectListItem>)ViewData["CategoryID"], new { @class = "textbox" }) %> However, the articles category isn't selected when I go to that page. The ViewData I use for the DropDownList looks like this, ViewData["CategoryID"] = new SelectList(categories, "CategoryID", "Title", article.CategoryID); Which should select the article.CategoryID as it's selected value. Have I done this wrong?

    Read the article

  • Deleting rows with MySQL LEFT JOIN

    - by fabrik
    Hello! I have two tables, one for job deadlines, one for describe a job. Each job can take a status and some statuses means the jobs' deadlines must be deleted from the other table. I can easily SELECT the jobs/deadlines that meets my criteria with a LEFT JOIN: SELECT * FROM `deadline` LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szamlazva' OR `status` = 'szamlazhato' OR `status` = 'fizetve' OR `status` = 'szallitva' OR `status` = 'storno' (status belongs to job table not deadline) But when i'd like to delete these rows from deadline, MySQL throws an error. My query is: DELETE FROM `deadline` LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szamlazva' OR `status` = 'szamlazhato' OR `status` = 'fizetve' OR `status` = 'szallitva' OR `status` = 'storno' MySQL error says nothing: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szaml' at line 1 How can i turn my SELECT into a working DELETE query? Thanks, fabrik

    Read the article

  • Python - How to find a correlation between two vectors ?

    - by psihodelia
    Given two vectors X and Y I have to find their correlation, i.e. their linear dependence/independence. Both vectors have equal dimension. A resulted answer should be a floating point number from [-1.0 .. 1.0]. Example: X=[-1, 2, 0] Y=[ 4, 2, -0.3] Find y=cor(X,Y) such that y belongs to [-1.0 .. 1.0]. It should be a simple construction involving a list-comprehension. No external library is allowed. UPDATE: ok, if dot product is enough, then here is my solution: nX = 1/(sum([x*x for x in X]) ** 0.5) nY = 1/(sum([y*y for y in Y]) ** 0.5) cor = sum([(x*nX)*(y*nY) for x,y in zip(X,Y) ]) right?

    Read the article

  • Rails Habtm with a field

    - by moshimoshi
    Hello, Is that possible to have a field in a has and belongs to many table? Just like favorite: create_table :messages_users, :id => false, :force => true do |t| t.integer :message_id, :null => false t.integer :user_id, :null => false t.boolean :favorite, :null => false t.timestamps end I saw timestamps works well, thanks to ActiveRecord. But when I try to add favorite into the table and then I try: Message.first.users << User.first Then I get this error message: ActiveRecord::StatementInvalid: SQLite3::SQLException: messages_users.favorite may not be NULL: INSERT INTO "messages_users" ("created_at", "message_id", "updated_at", "user_id") VALUES ('''2010-05-27 06:07 :50.721512''', 1, '''2010-05-27 06:07:50.721512''', 1) I would like to use a habtm, I don't like has_many foo though bar association :) Is that possible? Thanks a lot.

    Read the article

  • How to sort list items for Date field value (Apex, Salesforce)

    - by Channa
    With Salesforce's Apex, is there any way to sort list items, for Date field value. Please refer the TODO section of the following code, thanks. /** * Select list of jobOccurrences belongs to particular list of jobs */ private List<Job_Occurrence__c> getJobsByJobCode(List<Job__c> jobList) { // Select relevant Job Occurrence objects List<Job_Occurrence__c> jobOccuList = new List<Job_Occurrence__c>(); for (Job__c job : jobList) { Job_Occurrence__c jobOccurrence = [SELECT Id, Job__c, Schedule_Start_Date__c FROM Job_Occurrence__c WHERE Job__c =: job.Id]; if((jobOccurrence != null) && (jobOccurrence.Id != null)) { jobOccuList.add(jobOccurrence); } } if((jobOccuList != null) && (jobOccuList.size() > 0)) { // TODO // How I sort the 'jobOccuList' with Date field 'Schedule_Start_Date__c', // for select the items according to sequence of latest jobOccurrence return jobOccuList; } else { throw new RecordNotFoundException ('Could not found any jobOccurrence for given list of jobs'); } }

    Read the article

  • Editing Subversion post-commit script to enable automated Hudson builds

    - by Wachgellen
    Hey guys, I'm not so good with Linux, but I need to modify the post-commit file of my Subversion repository to get Hudson to build automatically on commits. This page here tells me to do this: REPOS="$1" REV="$2" UUID=`svnlook uuid $REPOS` /usr/bin/wget \ --header "Content-Type:text/plain;charset=UTF-8" \ --post-data "`svnlook changed --revision $REV $REPOS`" \ --output-document "-" \ http://server/hudson/subversion/${UUID}/notifyCommit?rev=$REV The part that I don't know is the address URL given at the bottom of that code snippet. I know the address of my Hudson server, but the /subversion part has me baffled, because on my system that doesn't refer to anything. My Subversion repository belongs somewhere else on the server, not inside Hudson. Can anyone tell me what I'm supposed to put as the URL (an example would help greatly)?

    Read the article

  • Retreive list of students registered for a particular course

    - by Pankaj Khurana
    Hi, I have moodle1.9 installed on my system and writing some custom reports. I want to retrieve list of students registered for a particular course. I have user profile field usercategoryid through which i figure out for which category he has enrolled. Course belongs to a particular category. Through mdl_user_info_data table i retrieve the category for a particular user. I have written a query to retrieve the users who have registered for a particular category for e.g. Financial Planning 2010. But the issue is that i now want users who have registered for a particular course for e.g. Insurance Planning. There is a relation between course and course category but i am unable to find out the table where course and user information is linked. Please help me on this Thanks

    Read the article

  • Nested joins hide table names

    - by Sergio
    Hi: I have three tables: Suppliers, Parts and Types. I need to join all of them while discriminating columns with the same name (say, "id") in the three tables. I would like to successfully run this query: CREATE VIEW Everything AS SELECT Suppliers.name as supplier, Parts.id, Parts.description, Types.typedesc as type FROM Suppliers JOIN (Parts JOIN Types ON Parts.type_id = Types.id) ON Suppliers.id = Parts.supplier_id; My DBMS (sqlite) complains that "there is not such a column (Parts.id)". I guess it forgets table names once the JOIN is done but then how can I refer to the column id that belongs to the table Parts?

    Read the article

  • QuestionOrAnswer model?

    - by Mark
    My site has Listings. Users can ask Questions about listings, and the author of the listing can respond with an Answer. However, the Answer might need clarification, so I've made them recursive (you can "answer" an answer). So how do I set up the database? The way I have it now looks like this (in Django-style models): class QuestionOrAnswer(Model): user = ForeignKey(User, related_name='questions') listing = ForeignKey(Listing, related_name='questions') parent = models.ForeignKey('self', null=True, blank=True, related_name='children') message = TextField() But what bugs me is that listing is now an attribute of the answers as well (it doesn't need to be). What happens if the database gets mangled and an answer belongs to a different listing than its parent question? That just doesn't make any sense. We can separate it with polymorphism: QuestionOrAnswer user message created updated Question(QuestionOrAnswer) shipment Answer(QuestionOrAnswer) parent = ForeignKey(QuestionOrAnswer) And that ought to work, but now ever question and answer is split into 2 tables. Is it worth this overhead for clearly defined models?

    Read the article

  • Ajax foreign key filter in Django admin interface

    - by Googol
    http://blog.philippmetzler.com/?p=52 Just tried django-ajax-filtered-fields and like it very much. I’m looking for a solution for this problem: My model looks like this: class Song(models.Model): Album = models.ForeignKey(Album) class Artist(models.Model): album = models.ForeignKey(Album) song = models.ForeignKey(Song, blank=True, null=True) So the user has to define a topic. He can also define a subtopic but doesn’t have to. The subtopic belongs to a topic. In the admin interface I’d like to limit the choices for subtopic based upon what he selects in topics. That should change dynamically with AJAX. I will have a closer look to django-ajax-filtered-fields but didn’t find a solution to that specific problem. Perhaps it’s another usecase for django-ajax-filtered-fields in general? Or do you know another solution to my specific requirements?

    Read the article

  • Why doesn't C have rotate left/right operators?

    - by icepack
    A bit of a philosophical question, I suppose. Hope it belongs here. C language has the standard set of bit-wise operations, including OR, AND, XOR, SHIFT LEFT/RIGHT, NOT. Anyone has an idea why rotate left/rotate right isn't included in the language? These operators are of the same complexity as other bit-wise operators and normally require a single assembly instruction, like the others. Besides, I can think of a lot of uses for rotate operator, probably not less than, say, xor operator - so it sounds a bit strange to me that they aren't included in C along with the rest. Edit: Please stop suggesting implementations of rotation operators. I know how to do that and it's not what the question about.

    Read the article

  • Creating 'select' listboxes using FormHelper in CakePHP

    - by joec
    I have two models Category and Point. The associations are defined as: Category hasMany Point Point belongsTo Category I would like, when adding Points to my database, to be able to select the category it belongs to from a <select> box, along with the rest of the form data. Where would i need to set the category list and how could i do it? And how would i produce the select box? I assume it could be done with $form->input('categorieslist',array('type'=>'select')); //categorieslist needs //setting somewhere. But i am fairly new to Cake and not done much with associations before. Thanks.

    Read the article

  • Getting 'this' pointer inside dependency property changed callback

    - by mizipzor
    I have the following dependency property inside a class: class FooHolder { public static DependencyProperty CurrentFooProperty = DependencyProperty.Register( "CurrentFoo", typeof(Foo), typeof(FooHandler), new PropertyMetadata(OnCurrentFooChanged)); private static void OnCurrentFooChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FooHolder holder = (FooHolder) d.Property.Owner; // <- something like this // do stuff with holder } } I need to be able to retrieve a reference to the class instance in which the changed property belongs. This is since FooHolder has some event handlers that needs to be hooked/unhooked when the value of the property is changed. The property changed callback must be static, but the event handler is not.

    Read the article

  • search engine (solr/sphinx) question

    - by noname
    i want to make my threads content searchable with full text search engines like solr. but i wonder one thing. should i index just the thread.title, thread.body and post.body or should i index username, created date, nr of posts, views, country, region and city too that belongs to thread? i mean when an user search for a thread he will get hits returned containing thread title, 2 lines of body, which user has posted it, creation date, tags, and so on. should i index all this information too? but then it would be pretty much the whole database. or should i just index the 3 first columns i mentioned for full text search. and another question. when an user post a new thread, then i have to immidiately tell solr to add that row? if im not, how would it be searchable?

    Read the article

  • Django many-to-many relationship to self with extra data, how do I select from a certain direction?

    - by Jake
    I have some hierarchical data where each Set can have many members and can belong to more than one Set(group) Here are the models: class Set(models.Model): ... groups = models.ManyToManyField('self', through='Membership', symmetrical=False) members = models.ManyToManyField('self', through='Membership', symmetrical=False) class Membership(models.Model): group = models.ForeignKey( Set, related_name='Members' ) member = models.ForeignKey( Set, related_name='Groups' ) order = models.IntegerField( default=-1 ) I want to know how to get all the members or all the groups for a Set instance. I think I can do it as follows, but it's not very logical, can anyone tell me what's going on and how I should be doing it? # This gives me a set of Sets # Which seems to be the groups this Set belongs to set_instance.set_set.all() # These give me a set of Memberships, not Sets set_instance.Members.all() set_instance.Groups.all() # These they both return a set of Sets # which seem to be the members of this one set_instance.members.all() set_instance.groups.all()

    Read the article

  • Where to put to_xls and from_xls in a rails app

    - by Joe Arasin
    So I have a model that I need to be able to serialize to/read from an Excel(XLS) document. I am a bit of a loss as to where this code actually belongs. My initial thought is that the to_xls is a view, but after poking around and seeing things like (to|from)_xml and (to|from)_json in ActiveRecord, I was wondering if maybe this stuff belonged in the model. Alternatively, does it belong in just a whole separate container somewhere? For what it's worth, users will be downloading models from the site, modifying them in excel, then posting them.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >