|
Hello guys, I think this is more a python question than Django.
But basically I'm doing at Model A:
from myproject.modelb.models import ModelB
and at Model B:
from myproject.modela.models import ModelA
Result:
cannot import name ModelA
Am I doing something...
Started by Clash on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
So, instead.
In Django you can fix this by referring to a model by name instead of by class object.
|
|
(That is, the model that you pass to the view and the model that you get back once the form posts.)
If not, is it better to do so anyways? What if there is data you are gathering that is beyond what the view page model has a property for?
Started by Ryan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The model extra properties on the....
No they don't have to be the same, you would probably have a fair bit of overlap though .
Are talking about the model that you pass to the view and the model that you get back once the form posts.
|
|
Hello guys,
I've looked at formset and model formset at Django many times, but I still can't figure the smart way to do this.
I have two models:
Group
Person
I have a queryset that contains all the persons trying to join a particular group: Person.objects...
Started by Clash on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In your view, check the value of the hidden field to... .
On the onclick event of the Accept and Reject buttons, set the value of the hidden field appropriately and then submit the form .
At the top of my head, you can insert a hidden field called 'Action' .
|
Ask your Facebook Friends
|
It used to be that within a CodeIgniter model you couldn't access another model. E.g
$this->load->model('bar'); $this->bar->something();
Would be invalid within the code of a model. Is this still valid or have they changed it?
Started by Click Upvote on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You wouldn't necessarily want to access the model in your controller and pass....
For instance, if you needed to check if someone is authorized to go are using (its probably auto-included in most cases) .
The libraries in your model if need be.
|
|
I have a model with a FileField and a form that has a FileField as well. The form is not a ModelForm based on the model but it's a regular Form.
How do I save the uploaded file from the form to the model?
Started by TomA on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If your model is
class Thing(models.Model): document = models.FileField(upload_to='documents')
you can.
|
|
I want to apply the "ordering" Meta option to the Django model User from django.contrib.auth.models. Normally I would just put the Meta class in the model's definition, but in this case I did not define the model. So where do I put the Meta class to modify...
Started by hekevintran on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The only issue with it is that you need....
The standard User model has no ordering defined support.
This is how the Django manual recommends you do it :
You could also use a proxy model to define a different default ordering on a model.
|
|
I have a model and two views set up like this:
Model ---> OSortFilterProxyModel ---> OListView Model > OTableView
When the user selects something in one of the views, I want the other view to mirror that selection. So I thought I'd use a QSelectionModel...
Started by Marius on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
There....
You'll have to send the model index through the proxy model by platform.
These will pass you a model index.
I'm not sure if this would work, and it depends on what Qt .
model, the other is the sort filter model.
|
|
I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model.
Is there a way to access a model from...
Started by Eldila on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Class SomeModel extends Model { function doSomething($foo) { $CI =& get_instance(); $CI->load->model....
<?php // in your controller $model1 = new Model1 for a discussion .
A clear API and inject a model into your model.
|
|
I have a dialog box with two disctinct parts. Each part uses a model view design.
But when a model is updated, the second one has to be updated too. I’m wondering if it exists any best pratice or design pattern for communicating (update notification) ...
Started by Matthieu on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If each model can.
A common solution is to have the second model listen to the first model and update itself when the first model fires a change event.
You could use the Mediator design pattern.
|
|
When is the right time to use functions to set variables inside of my models, verse simply directly assigning them?
AKA...
When do I use:
$model->set('status','active');
...instead of:
$model->status = 'active';
Started by johnnietheblack on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Think about this:
What if your model has some variables that you don't want to be able to be read for a base model class in a MVC system..
|