If Statement django template

2023-01-12 Thread 'dtdave' via Django users
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

Restricting items to a specific user

2022-09-14 Thread 'dtdave' via Django users
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

LogIn Class Based View

2022-05-26 Thread 'dtdave' via Django users
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

Allocating items to users

2022-05-13 Thread 'dtdave' via Django users
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

Model Design

2022-05-05 Thread 'dtdave' via Django users
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

UpdateView Redirect

2020-08-31 Thread 'dtdave' via Django users
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

Custom User and Profile Model

2020-01-28 Thread 'dtdave' via Django users
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_

Import a float field using a script

2019-10-16 Thread 'dtdave' via Django users
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

Django Project Template

2019-09-09 Thread 'dtdave' via Django users
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

Re: What is the proper workflow before first migration?

2019-04-10 Thread 'dtdave' via Django users
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

Re: What is the proper workflow before first migration?

2019-04-06 Thread &#x27;dtdave&#x27; via Django users
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

Signals and Profile Update

2018-09-17 Thread &#x27;dtdave&#x27; via Django users
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

Re: Advice on Model Structures

2018-08-14 Thread &#x27;dtdave&#x27; via Django users
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

Re: Advice on Model Structures

2018-08-14 Thread &#x27;dtdave&#x27; via Django users
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

Advice on Model Structures

2018-08-13 Thread &#x27;dtdave&#x27; via Django users
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

Re: Django DateField

2018-07-08 Thread &#x27;dtdave&#x27; via Django users
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

Re: Django DateField

2018-07-06 Thread &#x27;dtdave&#x27; via Django users
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

Django DateField

2018-07-05 Thread &#x27;dtdave&#x27; via Django users
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

Django Import/Export ManyTo Many

2017-06-21 Thread &#x27;dtdave&#x27; via Django users
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

Custom Model Manager

2017-05-25 Thread &#x27;dtdave&#x27; via Django users
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

Link to urls containing slug

2017-01-31 Thread &#x27;dtdave&#x27; via Django users
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

Template Data

2016-11-18 Thread &#x27;dtdave&#x27; via Django users
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

Filters in Search

2016-10-20 Thread &#x27;dtdave&#x27; via Django users
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

Postcode Search

2016-08-23 Thread &#x27;dtdave&#x27; via Django users
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

Reverse URL django-admin

2016-07-25 Thread &#x27;dtdave&#x27; via Django users
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

Generic Foreign Key

2016-07-21 Thread &#x27;dtdave&#x27; via Django users
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 --