I have the following relationship in a model
class Contract(models.Model):
supplier = models.ForeignKey(
Supplier,
on_delete=models.CASCADE,
verbose_name="Supplier Name",
related_name="contract_suppliers",
)
I am trying to include an if statement in my temp
I have the following models:
class AccountManager(models.Model):
account_manager = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE
)
def __str__(self):
return str(self.account_manager)
class Client(models.Model):
account_manager = models
I have this function based view which works perfectly but I would like to
convert to a class based view but am stuck on how to do this:
This is my fbv:
def loginView(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
cd = form
I have the following code:
from django.conf import settings
from django.db import models
class AccountManager(models.Model):
account_manager = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True,
blank=True
)
class Meta:
verbose_name = 'Ac
We receive data from various third parties in their proprietary format in
excel. We then import this into our database and our models have been
designed around their format.
There is no option to change the way this data is received.
However, we now need to add an account manager to this data and
I have got myself into somewhat of a pickle.
Currently I have the following url structure:
path('/', views.PublisherDetailView.as_view(),
name='publisher_detail'),
path('/update/', views.PublisherUpdateView.as_view(),
name='publisher_update'),
In my views the following:
class PublisherUpdateVie
I have created a Custom User Model and a Profile model that is created when
a user registers with the site.
I just want some confirmation that my logic is right.
To avoid the error when creating a superuser "Custom users have no profile"
I have put the following in my settings.py:
AUTH_PROFILE_
I have the following field in my model:
area_hectares = models.FloatField(blank=True, null=True)
In my script for importing from a csv I seem to run into the following
error:
could not convert string to float
The relevant part of the script is as follows:
area_hectares=float(row[6])
Could someo
I have been using Django-cookiecutter to create my projects.
I have then decided that there was too much that I either didn't need or
had alternatives in particular having a single settings file using
django-configurations.
The first project building from scratch worked fine so I decided to cre
model have to be in a 'users'
> app?
>
>
> On Sat, Apr 6, 2019 at 10:26 AM 'dtdave' via Django users <
> django...@googlegroups.com > wrote:
>
>> The error you are getting is because the CustomUser is not included in
>> your settings.p
The error you are getting is because the CustomUser is not included in
your settings.py
Because I use a separte user model my settings.py has this line in it:
AUTH_USER_MODEL = 'users.CustomUser'
I would recommend that you have your Custom User as a separate user model.
For good tutorials on use
I have a Custom User Model and a separate Profile Model with django
all-auth.
The following signal creates the profile for the user and then informs the
admin that a new user has registered.
@receiver(post_save, sender=User)
def create_user_profile(sender, **kwargs):
'''Create a profile for
Many thanks
On Monday, 13 August 2018 22:44:05 UTC+1, mark wrote:
>
> dtdave,
>
> Basically, the model structure is how you indicated. To achieve changing
> the content of a select once the page is loaded, you will have to do some
> JavaScript magic. Django-select2 will do that for you, and ther
Many thanks
On Monday, 13 August 2018 17:57:03 UTC+1, Mikhailo Keda wrote:
>
> Create a 4 models:
> 1. Region
> 2. County (has a foreign key to Region)
> 3. Office (has a foreign key to County)
> 4. Employee (has a foreign key to Office)
>
> organise url by this pattern:
> /
>
> check this exa
I would like some advice as the best way with dealing with the following
model structure.
Region
Counties
Office
Employees
I would like to show the relevant counties in the relevant regions and then
to show the office in that county followed by the employees in that office.
In the view end user
Many Thanks
On Friday, 6 July 2018 16:13:35 UTC+1, Melvyn Sopacua wrote:
>
> On vrijdag 6 juli 2018 16:46:08 CEST 'dtdave' via Django users wrote:
> > Many thanks for the help on this. I have implemented the following:
> > models.py
> > start_date = mode
I know the answer is probably obvious, but for smoe raeson I cannot fathom
it out at the moment.
Again thanks for all the help
On Thursday, 5 July 2018 20:08:30 UTC+1, Melvyn Sopacua wrote:
>
> On donderdag 5 juli 2018 19:05:47 CEST 'dtdave' via Django users wrote:
>
> > How
I have a model that contains a datefield which signifies the start date for
a task.
My modelmanager filters the tasks by the start date and the template lists
them in the date descending order. Everything is fine with this.
However, now I have been asked to change this so that some projects have
I have a model with a manytomany field as follows:
contact = ChainedManyToManyField(
'contacts.Contact',
chained_field="practice",
chained_model_field="practice",
)
Within my admin I have the following for import/export:
contact = fields.Field(column_name='contact
I apologise if this is a simple question but I am still somewhat new to
Dajngo.
I have the following models:
Jobs Model
Candidates Model
Applications Model
The jobs model has a manager on it as follows:
class ExpiredManager(models.Manager):
def get_queryset(self):
return super(Expire
Within my model I have the following that links through to a detail page.
def get_absolute_url(self):
kwargs = {
'job_id': self.job_id,
'slug': self.slug,
}
return reverse('job_detail', kwargs=kwargs)
Ev
As still learning django I have a simple issue.
I have the following models:
class Contactnumber(TimeStampedModel):
phone_number = models.CharField(max_length=100, unique=True)
contact = models.ForeignKey(‘contacts.Contact')
class Contact(TimeStampedModel):
contact = models.CharFi
I have an issue that I have got myself into a mess trying to solve, so any
help would be appreciated.
I have implemented a simple search solution that works fine and this is my
view:
from django.shortcuts import render
from django.views.generic import ListView
from jobs.models import Job
from d
I am looking to add the facility to "find my nearest" by postcode to my
django app.
Does anyone have any recommendations for this facility?
Many thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group
I apologise in advance for the length of my post but I have included all
the detail I can.
I have the following structure for an app. The list view template uses
Bootstrap DataTables. My question is how to amend the urls to return the
change url in django-admin.
models.py
def get_absolute_ur
I have two models notes and counties which are used across multiple models.
At the moment the realtionship is done using a foreign key.
I am getting conflicting advice on whether to use a Generic Foreign Key.
Could someone please enlighen me as to the best practice?
Many thanks in advance
--
26 matches
Mail list logo