w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how to find all many to many objects for parent of parent object in django
For a customer object, groups = Group.objects.filter(location__customer = customer).distinct() Documentation on lookups across relationships

Categories : Django

Django REST framework: Can a nested object access its parent object's details in a List View?
Moment of clarity: the solution is to use a SerializerMethodField to instantiate the RepSummarySerializer and pass the customer_id in the context: class CustomerSummarySerializer(serializers.HyperlinkedModelSerializer): id = ... name = ... rep = serializers.SerializerMethodField('get_rep') def get_rep(self, obj): rep = obj.rep serializer_context = {'request': self.context.get('request'), 'customer_id': obj.id} serializer = RepSummarySerializer(rep, context=serializer_context) return serializer.data The customer_id can now be accessed in RepSummarySerializer.get_rep_url like this: def get_rep_url(self, obj): customer_id = self.context.get('customer_id') ... Don't know why I didn't think of this thr

Categories : Django

NUnit - Loads ALL TestCaseSources even if they're not required by current test
Could you do this by moving your sources instantiation to a helper method and call them in the setup methods for each set of tests? I often have a set of helper methods in my integration test suite that set up shared data for different tests. I call just the helper methods that I need for the current suite in the [Setup]

Categories : C#

Nested routes loads the parent model
Ember will automatically call User.find(123) when you hit /user/123/... because that is the default model hook for App.UserRoute. If you want to fetch additional data when the followers route is accessed, define a model hook for App.UserFollowersRoute: App.UserFollowersRoute = Ember.Route.extend({ model: function() { user = this.controllerFor('user'); // Now find and return the list of followers } });

Categories : Ember Js

Is the practice of passing parent object as reference for parent object interaction Evil?
This is actually a decent way of de-coupling classes from each other - what you've written looks a lot like the visitor pattern. Your example as written doesn't have much of a memory impact at all, because SomethingService doesn't hold onto ManagerParentClass except for the length of that method. If we were to assume instead that SomethingService would save such an instance during construction or regular methods, then it's slightly more complicated. Having SomethingService hold a reference to ManagerParentClass means that ManagerParentClass is going to be held in reference 1) as long as SomethingService is held in memory through some chain of references that lead back to a GC root and 2) as long as SomethingService maintains its reference to MPC. If SS were to release its reference (nu

Categories : C#

Remove Scrollbars from Parent Window when Fancybox Loads
You just need to set the overflow:hidden on the div with the scrollbar when you click on the link. Never really used jfiddle, but according to that just over riding the class in the fancybox css will do the trick. Throw this in one of your custom css files: .fancybox-lock .fancybox-overlay { overflow:hidden; } make sure to load your custom css after you load the fancybox css so yours takes precedence. Be careful with this, because if one of the pictures you are overlaying is extermely tall (taller than your current window view) then you won't be able to see the whole image. You can use some javascript to resize the image according to the height of the window if this is a pressing issue.

Categories : CSS

Should objects of a collection member of parent object also reference the parent object?
You can have circular references, and they can be very useful. Most ORMs deal with them nicely. However, if you use serialization libraries, then they can be a bit tricky and often don't like circular references. But whether you should or shouldn't use them depends a lot on the problem you are solving. Two (or more) things that hold references to each other (an object graph) won't keep themselves alive if that graph becomes isolated from a root reference. However you can accidentally end up holding on to large graphs of things just by holding a reference to one thing in the object graph.

Categories : C#

LINQ2SQL: Using the parent ID in a child object twice - parent ID equals zero
The key is not to think database style, but ORM style. So instead of setting keys, you assign entities. so change ToDoAssignmentID = workOrder.AssignmentID to (most probable guess of tablenames, check the definition of your entity) the following assignment of entities ToDoAssignment = workOrder This will be handled during SubmitChanges as well.

Categories : C#

three.js object is black before texture loads - can I change this behavior?
Not sure if you already cleared this up but I made a handy little function to take care of this by modifying the opacity setting, the basic of which are: function loadTexture( path ){ var mat = new THREE.MeshBasicMaterial({ map: new THREE.ImageUtils.loadTexture( path, null, function() { mat.opacity = 1; } ), opacity: 0 }); return mat; }

Categories : Three Js

Django - Is ManyToManyField required to use over ForeignKey?
ForeignKey and ManyToMany are two different things. You probably mean ForeignKey v/s OneToOne An example: Lets take some arbitrary Developer model class Developer(models.Model): user = models.OneToOneField(User) #ensure there is a one-to-one relationship between User and Developer model - One user object in django.contrib.auth can be associated with only one Developer and vice versa category = models.ManyToMany(Category) #Developer can be part of many categories, and also one category can be associated with many developers birth_address = models.ForeignKey(Address) #He can have only birth place. The address can be associated with many, so it is a `OneToMany` relationship So, ManyToMany is many-to-many relationship and ForeignKey is a restricted ManyToMany (a many-to-one r

Categories : Django

Error : An object reference is required for the non-static field, method, or property 'Microsoft.Win32.RegistryKey.SetValue(string, object)'
You have created an instance of RegistryKey class. So its not a static class, but you are trying to use the class as it being a static class. Just use its object(registryKey) that you have initialized earlier and it will be fine. Therefore, replace RegistryKey.SetValue("EmailID", eid);//Error at this Line with registryKey.SetValue("EmailID", eid); From MSDN: You can define a class as static if you want to guarantee that it can't be instantiated, can't derive from or serve as the base for another type, and can contain only static members. Because you can't create an instance of a static class, you can't use the new keyword to create a variable of the class type. You must access the members of a static class by using the class name itself. For example, if you have a static

Categories : C#

Django JSON Error - "This field is required"
It isn't clear if you're actually sending JSON as the data you paste in from Charles is in no particular format. Check the headers and the "JSON text" tab (if it exists). Also, change your request descriptor: RKRequestDescriptor *requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:[driverMapping inverseMapping] objectClass:[Driver class] rootKeyPath:nil];

Categories : Arrays

Django-CMS Type Error "a float is required"
As I wondered, the problem was that I was accessing the site using my temporary link from BlueHost, which the function throwing the error could not handle. When my clients finally pointed their domain name at the server this problem and a few others (CSS inconsistencies in the Django admin, trouble with .htaccess) disappeared. Everything is up now and working fine.

Categories : Python

How do i update object using php-sdk? (The parameter object is required)
I have been facing the same issue for the past couple of days, in the end I stopped trying to use the Facebook PHP SDK to send the request and resorted to using just sending a HTTP Request. I am creating an object rather than updating one, but the implementation shouldn't differ much from your needs. I was getting the same error (The parameter object is required) and the below implementation resolved that issue. I used the vinelab HTTP client composer package and built a request like this: $request = [ 'url' => 'https://graph.facebook.com/me/objects/namespace:object', 'params' => [ 'access_token' => $fbAccessToken, 'method' => 'POST', 'object' => json_encode([ 'fb:app_id' => 1234567890,

Categories : PHP

Blank, Null, and Required in Django Models and ModelForms
It depends on the requirement. Sometime we decide later to make field mandatory on the form although on model it is still not required. But the form will ensure that field must be fill. You can have null=True on the model and then later you can make that field mandatory on form. But you can not make a field optional in form when it is mandatory on model that will result in database error later on.

Categories : Django

Make BooleanField required in Django Rest Framework
There was an issue with Boolean fields and the required argument. Should now be fixed in master. See this issue: https://github.com/tomchristie/django-rest-framework/issues/1004

Categories : Django

Django bulk create for models with multiple required fields
You can do it like this: demographic = Demographic.objects.get(id=7) PersonDemographic.objects.bulk_create( [PersonDemographic(person=person, demographic=demographic) for person in Person.objects.some_query_set()] )

Categories : Django

giving initial value raises 'value for field is required' error in django
Instead of adding this field dynamically, define it in the class appropriately: class EditQuestionForm(PostAsSomeoneForm, PostPrivatelyForm): title = TitleField() tags = TagNamesField() thread_type = forms.ChoiceField(choices=choices, widget=forms.Select) When creating the form instance set an intitial value if needed: form = EditQuestionForm(initial={'tread_type': thread_type}) And if you dont need this field, just delete it: class EditQuestionForm(PostAsSomeoneForm, PostPrivatelyForm): def __init__(self, *args, **kwargs): super(EditQuestionForm, self).__init__(*args, **kwargs) if some_condition: del self.fields['thread_type'] When saving form, check: thread_type = self.cleaned_data['thread_type'] if 'thread_type' in self.cleaned_data

Categories : Django

How to partially validate form, only non-blank fields, even when they are required, in Django?
One approach would be to iterate through the form fields setting required=False prior to validation. In your ajax view, something like this should work: for field in myform.fields.itervalues(): field.required = False json_result = json.dumps({'form_valid': myform.is_valid()})

Categories : Django

django-rest-framework - trying to set required=False flag on nested 1-to-M?
Checking the Serializer Relation Docs, first you need to add many=True to your cartitems field. Unfortunately this is read-only. The docs just say "For read-write relationships, you should use a flat relational style" — you can find a question about that here (although that's only dealing with the 1-1 case). Current strategies involve making cartitems read-only and then either: doing something post_save, using a second serializer or making a separate request to a separate endpoint to set the related entities. Given that better support for Nested Writes is coming I'd probably be inclined towards a separate request to a separate endpoint for the moment (though that will obviously depend on your constraints). I hope that helps. EDIT: (After update to question & discussion in comment

Categories : Django

Making a foreign key User model extension in Django required
In django 1.3.1 I use this code and works fine: from django.contrib.auth.models import User class FilterSearchQueries(models.Model): title = models.CharField(max_length=250) owner = models.ForeignKey(User) place = models.CharField(max_length=250) query = models.TextField()

Categories : Python

check status every time a login required view is accessed in django
In this case you would make a decorator like @login_required in django. I will send you to a great question that shows you how to do this. Here is the link.

Categories : Django

Django forms.FileField(required=True) is passing validation if empty
It raises key error because you have to call super's clean method first in order to get self.cleaned_data set. def clean(self): super(BucketUploadForm, self).clean() upload_to = '/some/path' upload_to += self.cleaned_data['file'].name You should take a look at how Form and Field validation works. It is a very enlightening read if you use to work with Django's Forms. Hope this helps!

Categories : Django

Error: "dictionary update sequence element #0 has length 1; 2 is required" on Django 1.4
Error in your question is raised when you try something like following: >>> a_dictionary = {} >>> a_dictionary.update([[1]]) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: dictionary update sequence element #0 has length 1; 2 is required It's hard to tell where is the cause in your code unless you show your code, full traceback.

Categories : Python

Prototypal Inheritance Why Does Child Object Not Inherit Method From Parent Object?
It should be Cat.prototype = Object.create(Mammal.prototype), that's where the methods are, not on Mammal directly. http://jsfiddle.net/GPNdM/1/

Categories : Javascript

What happens when you reference a DOM object (var o=docume...) and that DOM object is removed via parent.innerHTML=''?
Your fiddle makes things worse :) Why you need to know type of removed element? It will be object before it removed, and after too. If question what happens: Your element is Element. You can check it with i instanceof Element. It's just disconnected from DOM. You actually can connect it again, in other or the same place of DOM and it will be legal. If question how to check element is connected to DOM: just check if it's parent defined. if (i.parentElement) { // i connected to DOM } else { // i disconnected }; Think about: when you add new element with document.createElement, your new element not attached yet. But it obviously not undefined.

Categories : Javascript

Is it bad practice to have a child object have a reference to its parent object instead of a pointer?
People will argue about it all day long but references are just limited pointers. Don't agonize about which to use. The advantage of a pointer is you can copy childs, or create a child without a parent, to be given one later. If you need to do this, you have to use a pointer. If not, use whichever makes you feel warmest inside. It just isn't worth worrying about. If you make the pointer Parent *const parent_ it is effectively the same as a reference.

Categories : C++

Parent Object insert into two times when Child object inserted
When you do a TimeTableVO.addClassTable(ClassTableVO ct) remember to set ClassTableVO.timetable: public void TimeTableVO.addClassTable(ClassTableVO ct){ if(classtable.add(ct)){ ct.setTimetable(this); } } so link are correctly setter and Hibernate know ho to correctly cascade object while saving

Categories : Spring

Pass child object to function which requires parent object
There's no relation between Vectors parameterized with different types in Actionscript. Unfortunately, there's nothing you can really do about this. There's no equivalent like Java's List<? extends Spaceship>. Why not just use Vector.<Spaceship> and fill it with EnemySpaceships?

Categories : Actionscript

how to convert parent object with child object list into xml file using c#?
XmlSerializer doesn't support IList<T> interface. You have several options: change type from IList<T> to concrete class (e.g. List<T>); use DataContractSerializer instead of XmlSerializer; implement IXmlSerializable; create fake property of type List<T> for XmlSerializer reading and writing to classSubjectList and mark classSubjectList with [XmlIgnore] attribute.

Categories : Dotnet

force prototype to have new parent-object in new instance of object
If privateness is more important to you than using prototype (prototype methods cannot access private instance variables) and you're not planning on cloning your instances ("private" instance variables can only be accessed by the instance not by the class as in Java). With inheritance then overriding parent's funcitons will be more complicated but there are ways to do it: (put all "class" code in the constructor function) How to call parent class' method from a subclass in JavaScript so that parent's local variables would be accessible? I never use "private" instance variables but Bergi's suggestion to use module pattern is a good one to have "private" functions (not unique per instance) since a function can be the same for all instaces. Added this as an answer instead of a comm

Categories : Javascript

C++: Propagation of information from child object to parent object
Giving the Employee a pointer to its Supervisor is the traditional method for arranging for callbacks or progress reports. (That's your solution number three.) It's only one pointer. If you have enough employees that you're worried about the memory use (i.e. a few thousand of them), you can reduce the size by using a smaller handle rather than a pointer. That is, something like typedef uint8_t SupervisorHandle; class Employee { private: SupervisorHandle s; Supervisor& getSupervisor() { return startup.getSupervisor(s); } // ... }; If you place the handle sensibly around your other fields, it need only take a byte, and now you can have up to 256 supervisors. But this comes at the cost of flexibility: it ties you to the static Corporation instance, and add

Categories : C++

Error 424 Object required on End Sub
I tried something simple and it didn't compile (a variable name same as the Sub name). May be you should define and use a Long type variable lngDeleteRow: Sub DeleteRow() Dim lngDeleteRow as Long Debug.Print "ActiveWorkbook: " & ActiveCell.Worksheet.Parent.Name Debug.Print "ActiveSheet: " & ActiveCell.Worksheet.Name Debug.Print "ActiveCell: " & ActiveCell.Address If Err.Number <> 0 Then Debug.Print "DeleteRow() : ERR " & Err.Number & " " & Err.Description Err.Clear End If lngDeleteRow = ActiveCell.Row If ActiveWorkbook.Worksheets("Major Projects").Range("A" & lngDeleteRow) = "x" Then ActiveWorkbook.Worksheets("Major Projects").Rows(lngDeleteRow).EntireRow.Delete Else MsgBox "You haven'

Categories : Excel

VBA If-Then Object Required Error
I don't do much VBA for apps, but in VBScript Left(..) returns the left character, which doesn't make sense to assign something to it. You could try something like this: Cells(5, 3).Formula = "=" & Right(Cells(5, 3).Formula, Len(Cells(5, 3).Formula) - 1) This sets the Forumla to the current value of the Formula replacing the 1st character with an "=".

Categories : Vba

object required error Sheet1
I can't make comments, so I'll leave an answer, but are you sure lRow is returning a value? You could be trying to do: Sheets("Sheet1").Cells(NULL + 1, counter) = Cells(Cell.Row, counter) Also Try Sheets("Sheet1").Cells(lrow + 1, counter).Value = Cells(Cell.Row, counter) ALSO Your Cells(Cell.Row,Counter) is not part of a worksheet object

Categories : Vba

Why am I getting Run-time Error 424 Object Required?
The 424 error is caused by these two lines: Dim myLocation As Range Set myLocation = Application.Match(partsFormat, Range("C2:D1")) You've declared myLocation as a Range. You are then trying to set it to a number, which is what MATCH returns, not a Range. The Object that's required is a range. EDIT: In order to just Count the occurrences of partsFormat in Column C, use something like this: Dim partsFormat As String Dim partsFormatCount As Long partsFormat = "Part" partsFormatCount = Application.WorksheetFunction.CountIf(Range("C:C"), partsFormat) You'll obviously have to insert that into the right places in your code.

Categories : Excel

getelementbyid via msexcel vba object required 424
Here you go Instead of this URL http://fieldwork.genesisenergy.co.nz/ I am directly navigating to below frame src <frame name="Login" src="LoginGenesis.aspx?bgColor=FFFFFF&trimColor=FF6600" frameBorder="0" marginWidth="0" marginHeight="0" scrolling="auto"> Sub Website() Dim IE As Object, Doc As Object, UserName As Object, Password As Object, strCode As String Set IE = CreateObject("internetexplorer.application") IE.Visible = True ' IE.navigate "http://fieldwork.genesisenergy.co.nz/" IE.navigate "http://fieldwork.genesisenergy.co.nz/LoginGenesis.aspx?bgColor=FFFFFF&trimColor=FF6600" Do While IE.readystate <> 4: DoEvents: Loop Set Doc = CreateObject("htmlfile") Set Doc = IE.document Set UserName = Doc.g

Categories : Vba

When is a reference to the object class required?
Object provides an interface with functionality that the Java language designers felt all Java objects should provide. You can use Object when you don't know the subtype of a class, and just want to treat it in a generic manner. This was especially important before the Java language had generics support. There's an interesting post on programmers.stackexchange.com about why this choice was made for .NET, and those decisions most likely hold relevance for the Java language.

Categories : Java

PHP OOP How to call an object's parent method from the object itself?
$temp->parent::update() doesn't make sense. Why not just do parent::update() again instead of $temp->parent::update(); You have two methods named update() If you call $this->update() it will call the method from the object that a call made from. You can do parent::update(); This will run update() method in ObjectOne class

Categories : PHP

when I created a children object then how to get the parent's object
I know when I created the Children object,the same time ,a Parent object will be created ,is there any way to get the Parent object Only a child object is created, which has attributes from both the parent and child itself.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.