When you app depends on a custom user model

2021-10-09 Thread bnmng
Django "strongly recommends" you create custom user, and in your apps you 
can refer to the custom user with "settings.AUTH_USER_MODEL" or with 
get_user_model().  

Here's the problem.  If you develop an app which refers to the custom user, 
the migrations won't be portable because even if you use the 
above references, the migration will use the app name and model name of the 
custom user.  

Here's what a migration might look like: 
 
dependencies = [
('my_custom_auth_app', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='mymodel',
name='created_by',
field=models.ForeignKey(
  on_delete=django.db.models.deletion.CASCADE,
  to='my_custom_auth_app.my_custom_user',
),
),
 ]

Even though I never put "my_custom_auth_app" or "my_custom_user" in the 
app, it translated settings.AUTH_USER_MODEL to the app name and model for 
the migration.

Is there any way to get around this and make your app with its migrations 
portable?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com.


Re: When you app depends on a custom user model

2021-10-11 Thread bnmng
That's genius, David.  Thank you!

On Sunday, October 10, 2021 at 5:56:07 PM UTC-4 David Nugent wrote:

> Why not just edit the migration file directly and substitute 'my_custom..' 
> for settings.AUTH_USER_MODEL?
>
> There should be no problem in doing that.
>
> Regards, David
>
> On Sun, Oct 10, 2021 at 3:02 AM bnmng  wrote:
>
>> Django "strongly recommends" you create custom user, and in your apps you 
>> can refer to the custom user with "settings.AUTH_USER_MODEL" or with 
>> get_user_model().  
>>
>> Here's the problem.  If you develop an app which refers to the custom 
>> user, the migrations won't be portable because even if you use the 
>> above references, the migration will use the app name and model name of the 
>> custom user.  
>>
>> Here's what a migration might look like: 
>>  
>> dependencies = [
>> ('my_custom_auth_app', '0001_initial'),
>> ]
>>
>> operations = [
>> migrations.AddField(
>> model_name='mymodel',
>> name='created_by',
>> field=models.ForeignKey(
>>   on_delete=django.db.models.deletion.CASCADE,
>>   to='my_custom_auth_app.my_custom_user',
>> ),
>> ),
>>  ]
>>
>> Even though I never put "my_custom_auth_app" or "my_custom_user" in the 
>> app, it translated settings.AUTH_USER_MODEL to the app name and model for 
>> the migration.
>>
>> Is there any way to get around this and make your app with its migrations 
>> portable?
>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/812f80f3-f860-4d51-a4b0-9c5b2d5c8408n%40googlegroups.com.


Re: Quick question for web hosting production

2021-10-11 Thread bnmng
I'm not expert in doing this but the short answer is yes to both 
questions.  You might want to look into instructions for running Nginx and 
Apache together.  I haven't done this but there's a lot of info out there.  
Even if that's not exactly what you want it might help

On Friday, October 8, 2021 at 10:17:27 AM UTC-4 patz...@gmail.com wrote:

> I want to ask a quick question guys that, is it possible to host 2 apps in 
> one cloud service? like for example, angular for the front end and django 
> for the backend? and they would use one ip address right but on a different 
> port?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc5dcd3a-0e5f-47fa-82e5-f92a1e80784dn%40googlegroups.com.


Re: When you app depends on a custom user model

2021-10-11 Thread bnmng
One more note... I deleted the database and migrations and started clean 
again, and this time when I opened the migration file it had 
setting.AUTH_USER_MODEL the way I wanted it.  So I don't know why it didn't 
do that before.

On Monday, October 11, 2021 at 9:17:39 AM UTC-4 bnmng wrote:

> That's genius, David.  Thank you!
>
> On Sunday, October 10, 2021 at 5:56:07 PM UTC-4 David Nugent wrote:
>
>> Why not just edit the migration file directly and substitute 
>> 'my_custom..' for settings.AUTH_USER_MODEL?
>>
>> There should be no problem in doing that.
>>
>> Regards, David
>>
>> On Sun, Oct 10, 2021 at 3:02 AM bnmng  wrote:
>>
>>> Django "strongly recommends" you create custom user, and in your apps 
>>> you can refer to the custom user with "settings.AUTH_USER_MODEL" or with 
>>> get_user_model().  
>>>
>>> Here's the problem.  If you develop an app which refers to the custom 
>>> user, the migrations won't be portable because even if you use the 
>>> above references, the migration will use the app name and model name of the 
>>> custom user.  
>>>
>>> Here's what a migration might look like: 
>>>  
>>> dependencies = [
>>> ('my_custom_auth_app', '0001_initial'),
>>> ]
>>>
>>> operations = [
>>> migrations.AddField(
>>> model_name='mymodel',
>>> name='created_by',
>>> field=models.ForeignKey(
>>>   on_delete=django.db.models.deletion.CASCADE,
>>>   to='my_custom_auth_app.my_custom_user',
>>> ),
>>> ),
>>>  ]
>>>
>>> Even though I never put "my_custom_auth_app" or "my_custom_user" in the 
>>> app, it translated settings.AUTH_USER_MODEL to the app name and model for 
>>> the migration.
>>>
>>> Is there any way to get around this and make your app with its 
>>> migrations portable?
>>>
>>> -- 
>>>
>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/8cad467d-5fcc-4d22-9915-64290a1bc9a7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0cc78e3d-0d30-40de-8882-f88a8cd46956n%40googlegroups.com.


Re: X-frame options exempt

2021-11-02 Thread bnmng
I think the problem here is Google doesn't want to be embedded and there 
isn't much you can do about it.  If you can test it by replacing Google's 
URL with another one that works, then I think you proved your code is 
good.  

On Monday, November 1, 2021 at 8:53:52 AM UTC-4 greenk...@gmail.com wrote:

> Hi, 
>
> I am having issues with X-frame options exempt.  I keep getting the same 
> chrome error:
>
> “Refused to display 'https://www.google.com/' in a frame because it set 
> 'X-Frame-Options' to 'sameorigin'.”
>
> In my application I have performed the following combination of actions 
> and still have the error : 
>
>1. Removed X-frame middleware setting: 
>2. Changed X-frame Options:
>3. Utilized decorator @xframe_options_exempt
>4. Although I am looking to use this in a template, I also tested 
>Iframe directly in HTTPResponse 
>
>
> *Settings.py*
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
>
> ]
>
> X_FRAME_OPTIONS = 'ALLOWALL'
>
>  
>
> *Views.py*
>
> from django.shortcuts import render
> from django.http import HttpResponse
> from django.views.decorators.clickjacking import xframe_options_exempt
>
> @xframe_options_exempt
> def index(request):
> return HttpResponse('https://www.google.com/"; width = "100%" height = "100%">')
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f4861ae-9441-4dec-a7da-92f2e18a3ca6n%40googlegroups.com.


Custom User App

2021-11-10 Thread bnmng


Hi Django people. I request your thoughts on a custom user app. It's called 
'TougshireAuth', but my intent is that it be renamed and hacked each time 
it is added to a new project. Otherwise it's not really a custom user

I would appreciate feedback. I'm an amateur who is ready to accept honest 
criticism. 

 Thank you

https://github.com/tougshire/tougshire 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3ffb2e3f-c252-446c-a3ac-4377e7047190n%40googlegroups.com.


def post in ListView

2021-11-24 Thread bnmng
Hi everyone,

Is there anything dangerous about this?
class ItemList(ListView):
model = Item
def post(self, request, *args, **kwargs):
self.request.GET = self.request.POST
return super().get(request, *args, **kwargs)

I want to use this to accept filtering parameters from a form in a list 
view template. This ListView also has a get_queryset which returns a 
filtered query based on the parameters 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com.


Re: def post in ListView

2021-11-24 Thread bnmng
Thanks, though, Lalit.  

I realized I don't event have to do what I was originally doing.  I can 
just do this:

def post(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)
Then the post params are still available to the queryset method 
def get_queryset(self):
if self.request.POST.get('query_submitted'):
... do stuff ...



On Wednesday, November 24, 2021 at 12:14:21 PM UTC-5 sutharl...@gmail.com 
wrote:

> oh my bad that is available in django rest framework only
>
>
> On Wed, 24 Nov 2021 at 22:41, Lalit Suthar  wrote:
>
>> you can use `query_params`
>>
>> On Wed, 24 Nov 2021 at 19:04, bnmng  wrote:
>>
>>> Hi everyone,
>>>
>>> Is there anything dangerous about this?
>>> class ItemList(ListView):
>>> model = Item
>>> def post(self, request, *args, **kwargs):
>>> self.request.GET = self.request.POST
>>> return super().get(request, *args, **kwargs)
>>>
>>> I want to use this to accept filtering parameters from a form in a list 
>>> view template. This ListView also has a get_queryset which returns a 
>>> filtered query based on the parameters 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/aa7a1392-e388-4727-b412-bd1329daa6c4n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9e6d1ed0-0061-4e88-a715-c677d300461dn%40googlegroups.com.


dotenv - django-environ - etc

2021-12-28 Thread bnmng
Hi everyone,

I can't wrap my mind around why having my settings in a .env file is more 
secure than having them in a local_settings.py file, or why one of the 
various methods is better than another as long as you keep your local 
settings out of your version control.  Any opinions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2bd1faca-5e79-48cf-950e-81e5c4b6929fn%40googlegroups.com.


Re: dotenv - django-environ - etc

2021-12-30 Thread bnmng
Thank you for the replies.  I think I'm getting a better understanding of 
this.  I had been keeping the .env file in the project folder with the 
settings file, which seemed to offer no extra security  - hardly worth only 
being able to store settings as strings (using django-environ).  I'll take 
another look at the options and I'll move .env out of the project

On Tuesday, December 28, 2021 at 7:39:43 PM UTC-5 ber...@autofyle.com wrote:

> In all cases below, the .env file will exist outside of the Django project 
> and will be referenced from the settings file. This allows you to customize 
> and secure each environment while automating the whole build.
>
> *Developers*
> Local settings will point tot he location of the .env file. 
> This file is excluded from git via gitignore.
> Developers push to your repo's development branch which updates your 
> development server after passing CI/CD
>
>1. Developer 1 - /developer1Machine/whatever/unique path/.env
>2. Developer 2 - /unique path/.env/unique path/.env
>
> *Development environment*
> Developer settings references its own or same .env file path location 
> This directory and .env file permissions are secured such that only the 
> process running the web server has access to it and admin. So you may be 
> bale to log on to the server but won't be able to see this file and or 
> directory if you are not allowed to or in the right security group based on 
> your role.
>
>
> *Staging environment*
> Can be configured like development with staging desired tweaks.
> Testing and QA happens here prior to push to production
>
>
> *Production environment*
> Can be configured like staging.
> On Tuesday, December 28, 2021 at 3:41:25 PM UTC-7 Jason wrote:
>
>> an env file is basically imported into your OS environment, so you can 
>> retrieve them with the same interface.  That means you can easily include 
>> that with your build environment, or inject in some other means.  Can't do 
>> that with settings.
>>
>> Also, lets you keep one settings file, and use `os.environ.get()` 
>> anywhere you need to, which provides an identical interface.
>>
>> On Tuesday, December 28, 2021 at 2:58:28 PM UTC-5 bnmng wrote:
>>
>>> Hi everyone,
>>>
>>> I can't wrap my mind around why having my settings in a .env file is 
>>> more secure than having them in a local_settings.py file, or why one of the 
>>> various methods is better than another as long as you keep your local 
>>> settings out of your version control.  Any opinions?
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e0271ad-be6b-4036-8edf-b837b842eb43n%40googlegroups.com.


Specifying the value format for a DateTimeInput using type=datetime-local, especially when using inline formsets

2022-01-22 Thread bnmng
I think I found a fix to a bug that I don't know was affecting anyone other 
than me.

You can see a better formatted version of what I've typed below at 
https://bnmng.wordpress.com/2022/01/22/make-sure-the-widget-is-correct-in-a-django-inline-model-formset/

TL;DR: For a DateTimeInput widget where type=’datetime-local’, specify the 
default format to include the T in the middle of the date-time string:
widgets={ 'when':forms.DateTimeInput( format='%Y-%m-%dT%H:%M:%S', 
attrs={'type':'datetime-local'} ), ... } 

This was driving me crazy!

I had a model inline formset using a form:

forms.py:
TicketNoteFormset = inlineformset_factory(Ticket, TicketNote, 
form=TicketNoteForm, extra=10) 

The specified form (TicketNoteForm) had a widget specified for a DateTime 
field:

forms.py:
class TicketTicketNoteForm(forms.ModelForm): class Meta: model = TicketNote 
fields = [ 'when', 'text', ] widgets={ 
'when':forms.DateInput(attrs={'type':'date'}), 
'text':forms.TextInput(attrs={'class':'len100'}) } 

My mistake was using DateInput for the field ‘when’, which was a 
DateTimeField, not a DateField
models.py:
class TicketNote(models.Model): when = models.DateTimeField( 'when', 
default=datetime.now, help_text='The date that the note was submitted' ) 

In the HTML forms, the initial value, as expected, was a date-time value 
but the value attribute of the field was a date value without the time
  

The difference between initial and non-initial caused a record to be 
created even if the form was blank

*But it was still broken after I fixed it*

Leaving out the widget declaration works, but then I just get a plain text 
field and I want to take advantage of the browser’s popup calendar 

I thought I had the problem fixed by specifying the widget as 

forms.py:
DateTimeInput(attrs={'type':'datetime-local 
'}),
 


but that’s still giving me some problems. It worked fine in Firefox, but 
Chrome ignored the value attribute. So in Chrome
 

displays a blank datetime input and submits an empty string if not updated 

I’ll update if I find a good solution.

Update: This works in Firefox and Chrome:
forms.py:
widgets={ 'when':forms.DateTimeInput( format='%Y-%m-%dT%H:%M:%S', 
attrs={'type':'datetime-local'} ), ... } 

What Chrome was rejecting was having the value specified without the T 
between the date portion and the time portion. Django was producing the 
value without the T. By adding the format argument, I was able to make 
Django produce a default value that Chrome accepts. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d4b3bb1f-d296-4928-9e69-a0774acc5886n%40googlegroups.com.


Is there a function that returns common elements in multiple lists

2022-01-25 Thread bnmng
Hello,

Is there a built in function that compares two or more lists and returns 
elements common to all?

like this:
 
def in_both( list_a, list_b ):
list_c=[]
for value in list_a:
if value in list_b:
list_c.append(value)
return list_c

Or this:
def in_all(list_of_lists):
list_a = list_of_lists.pop(0)
list_b = []
for value in list_a:
in_all_lists = True
for each_list in list_of_lists:
if not value in each_list:
in_all_lists = False
if in_all_lists:
list_b.append(value)
return list_b

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bf2cf505-6205-4fcf-affd-9a0a2f7e5e00n%40googlegroups.com.


Re: Is there a function that returns common elements in multiple lists

2022-01-25 Thread bnmng
Thank you.  That set.intersection with list conversion seems like the way 
to go.  On your second point, well taken.  I'll keep that in mind for 
future Python questions

On Tuesday, January 25, 2022 at 7:46:58 AM UTC-5 bnmng wrote:

> Hello,
>
> Is there a built in function that compares two or more lists and returns 
> elements common to all?
>
> like this:
>  
> def in_both( list_a, list_b ):
> list_c=[]
> for value in list_a:
> if value in list_b:
> list_c.append(value)
> return list_c
>
> Or this:
> def in_all(list_of_lists):
> list_a = list_of_lists.pop(0)
> list_b = []
> for value in list_a:
> in_all_lists = True
> for each_list in list_of_lists:
> if not value in each_list:
> in_all_lists = False
> if in_all_lists:
> list_b.append(value)
> return list_b
>
> Thank you
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4465553d-8aa1-4ab2-9e9c-19c4117d623fn%40googlegroups.com.


Re: Is there a function that returns common elements in multiple lists

2022-01-26 Thread bnmng
Thank you.  I think I'll go with sets as advised, although this method also 
looks very neat: 
intersection = [item for item in list1 if item in list2] found at 
https://datagy.io/python-intersection-between-lists/ 

 
  

On Tuesday, January 25, 2022 at 3:11:10 PM UTC-5 joezep...@gmail.com wrote:

>
>
> On Tue, Jan 25, 2022 at 3:07 PM bnmng  wrote:
>
>> Thank you.  That set.intersection with list conversion seems like the way 
>> to go.  On your second point, well taken.  I'll keep that in mind for 
>> future Python questions
>>
>> On Tuesday, January 25, 2022 at 7:46:58 AM UTC-5 bnmng wrote:
>>
>>> Hello,
>>>
>>> Is there a built in function that compares two or more lists and returns 
>>> elements common to all?
>>>
>>> like this:
>>>  
>>> def in_both( list_a, list_b ):
>>> list_c=[]
>>> for value in list_a:
>>> if value in list_b:
>>> list_c.append(value)
>>> return list_c
>>>
>>> Or this:
>>> def in_all(list_of_lists):
>>> list_a = list_of_lists.pop(0)
>>> list_b = []
>>> for value in list_a:
>>> in_all_lists = True
>>> for each_list in list_of_lists:
>>> if not value in each_list:
>>> in_all_lists = False
>>> if in_all_lists:
>>> list_b.append(value)
>>> return list_b
>>>
>>> Thank you
>>>
>> -- 
>>
> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/4465553d-8aa1-4ab2-9e9c-19c4117d623fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/4465553d-8aa1-4ab2-9e9c-19c4117d623fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> Oussama Chafiqui
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fc7b49a3-2ca2-48e1-8556-f742e16fa4c9n%40googlegroups.com.


Re: relations

2022-01-26 Thread bnmng
I would start by defining Supplier in your models.py, then Shipment with a 
ForeignKey reference to Supplier

I'm assuming (forgive me if I'm wrong) that not only can a shipment have 
many species, but a species can be in many shipments, so if that's the 
case, the most obvious way is to go with ManyToMany for that relationship

https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_many/

class Supplier(models.Model):
(etc..etc..)

class Shipment(models.Model):
supplier = models.ForeignKey(
Supplier,
on_delete=models. (...etc.. etc...)

class Species(models.Model):
shipment = models.ManyToManyField(
Shipment,
(etc..)
On Monday, January 24, 2022 at 8:59:10 AM UTC-5 frank...@gmail.com wrote:

> I have tried several different ways but I cannot seem to get this right.  
> What I have is a list
> of suppliers.  Each supplier can have many shipments and each shipment can 
> have many species.  Seems simple enough but apparently I must be more 
> simple.
>
> I need a suggestion of how to relate these table.
>
> a supplier can have many shipment.  A shipment can have many species.  Any 
> help would be appreciated.  Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc667e81-ce32-4df5-8f88-47dff3d852c8n%40googlegroups.com.


Re: relations

2022-01-26 Thread bnmng
Hi,  

You shouldn't have to import since the models are in the same models.py  

On Wednesday, January 26, 2022 at 2:26:13 PM UTC-5 frank...@gmail.com wrote:

> After trying the suggestions I get these errors.
>
> supplier.models:
>
> class Supplier(models.Model):
>
> name = models.CharField(max_length=50)
>
> phone = models.CharField(max_length=15, null=True, blank=True)
>
> email = models.CharField(max_length=120, null=True, blank=True)
>
> country = models.CharField(max_length=120, null=True, blank=True)
>
> address = models.CharField(max_length=120, null=True, blank=True)
>
> city = models.CharField(max_length=120, null=True, blank=True)
>
> state = models.CharField(max_length=120, null=True, blank=True)
>
> zipCode = models.CharField(max_length=10, null=True, blank=True)
>
>
> def __str__(self):
>
> return self.name
>
>
> shipment.models:
>
> 
>
>
> from django.db import models
>
>
> from specie.models import Specie
>
> from supplier.models import Supplier
>
>
> # Create your models here.
>
>
>
> class Shipment(models.Model):
>
> created = models.DateTimeField()
>
> specie = models.ManyToManyField(Specie)
>
> label = models.CharField(max_length=10)
>
> received = models.PositiveIntegerField()
>
> bad = models.PositiveIntegerField(default=0)
>
> non = models.PositiveIntegerField(default=0)
>
> doa = models.PositiveIntegerField(default=0)
>
> para = models.PositiveIntegerField(default=0)
>
> released = models.PositiveIntegerField(default=0)
>
> entered = models.BooleanField(default=False)
>
> supplier = models.ForeignKey(Supplier, on_delete=models.DO_NOTHING)
>
>
> def __str__(self):
>
> return self.supplier
>
>
> class Meta:
>
> ordering = ["label"]
>
>
> def __str__(self):
>
> return self.label
>
>
> # =#
>
> When I add the line supplier = models.ForeignKey(Supplier, 
> on_delete=models.DO_NOTHING)
>
> I get this error:
>
>
> File "/Users/frankd/django_projects/Insectarium/src/shipment/models.py", 
> line 4, in 
>
> from supplier.models import Supplier
>
>   File 
> "/Users/frankd/django_projects/Insectarium/src/supplier/models.py", line 3, 
> in 
>
> from shipment.models import Shipment
>
> ImportError: cannot import name 'Shipment' from partially initialized 
> module 'shipment.models' (most likely due to a circular import) 
> (/Users/frankd/django_
>
>
>
> specie.models:
>
> --
>
> from django.db import models
>
> from django.utils import timezone
>
> from ckeditor.fields import RichTextField
>
>
> from shipment.models import Shipment
>
>
> # Create your models here.
>
>
>
> class Specie(models.Model):
>
> scientific_name = models.CharField(max_length=50)
>
> common_name = models.CharField(max_length=50, blank=True, null=True)
>
> description = RichTextField(blank=True, null=True)
>
> image = models.ImageField(
>
> upload_to="specie/images/species", default="no_picture.png"
>
> )
>
> shipment = models.ManyToManyField(Shipment)
>
> created = models.DateField(default=timezone.now)
>
>
> def __str__(self):
>
> return self.scientific_name
>
>
> class Meta:
>
> ordering = [
>
> "scientific_name",
>
> ]
>
>
> def __str__(self):
>
> return self.scientific_name
>
>
> # == #
>
> when I add the line shipment = models.ManyToManyField(Shipment)
>
> I get this error.
>
>
> File "", line 241, in 
> _call_with_frames_removed
>
>   File 
> "/Users/frankd/django_projects/Insectarium/src/shipment/models.py", line 3, 
> in 
>
> from specie.models import Specie
>
>   File "/Users/frankd/django_projects/Insectarium/src/specie/models.py", 
> line 5, in 
>
> from shipment.models import Shipment
>
> ImportError: cannot import name 'Shipment' from partially initialized 
> module 'shipment.models' (most likely due to a circular import) 
> (/Users/frankd/django_
>
>
>
> I think I tried this before but couldn't resolve these errors. Any 
> suggestions would be appreciated.
>
>
> frank-
>
>
> On Wed, Jan 26, 2022 at 10:53 AM frank dilorenzo  
> wrote:
>
>> Thank you so

Re: TemplateDoesNotExist at /

2022-06-05 Thread bnmng
What it the URL that is causing this error?

On Saturday, June 4, 2022 at 10:59:13 AM UTC-4 pm29...@gmail.com wrote:

> TemplateDoesNotExist at /home.html
> Request Method:
> GET
> Request URL:
> http://127.0.0.1:8000/
> Django Version:
> 4.0.3
> Exception Type:
> TemplateDoesNotExist
> Exception Value:
> home.html
> Exception Location:
> C:\Users\softy\AppData\Local\Programs\Python\Python310\lib\site-packages\django\template\loader.py,
>  
> line 47, in select_template
> Python Executable:
> C:\Users\softy\AppData\Local\Programs\Python\Python310\python.exe
> Python Version:
> 3.10.2
> Python Path:
> ['D:\\PYTHON COURSE RESOURCES\\BOOKS\\1 WEB DEVELOPMENT\\django ' 
> '1\\djangonautic\\djangonautic\\booktime\\booktime', 
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
>  
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\DLLs', 
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\lib', 
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310', 
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages',
>  
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32',
>  
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32\\lib',
>  
> 'C:\\Users\\softy\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\Pythonwin']
> Server time:
> Sat, 04 Jun 2022 08:16:02 +
> Template-loader postmortem
>
> Django tried loading these templates, in this order:
>
> Using engine django:
>
>- django.template.loaders.app_directories.Loader: 
>
> C:\Users\softy\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\admin\templates\home.html
>  
>(Source does not exist)
>- django.template.loaders.app_directories.Loader: 
>
> C:\Users\softy\AppData\Local\Programs\Python\Python310\lib\site-packages\django\contrib\auth\templates\home.html
>  
>(Source does not exist)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/204e76f9-1c4f-49a1-945e-368f76e7885dn%40googlegroups.com.


self.request.POST in get_context_data

2020-11-17 Thread bnmng
Hi. 

I can find dozens of examples of people using "if self.request.POST:" 
inside of get_context_data, but as far as I can tell there is no POST in 
get_context_data.  

I came across this in an answer in Stack Overflow: 

>> get_context_data() is only run for GET requests (assuming you are using 
a FormView), and not for POST requests handled by post() 
( 
https://stackoverflow.com/questions/38319384/passing-data-from-post-to-get-context-data
 
)

So I experimented and as far as I can tell you don't even need POST data to 
populate inline formsets.  So why are so many people under the impression 
that you can do anything with self.request.POST inside of get_context_data 
and why do so many people seem to think you have to use POST data to 
populate inline formsets?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1bc0952b-e3ee-4eb4-b038-10b515908eden%40googlegroups.com.


Using ModelForm to get labels in a DetailView

2021-09-19 Thread bnmng
I don't know if this is good practice, but to get field labels in a 
DetailView, it seems to work fine if you just add a form to the context:

views.py:

class ItemDetailView(DetailView):

model = Item
context_object_name = "item"

def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
context_data['form'] = ItemForm # just to get the labels
return context_data


item_detail_view.html:

{{ form.name.label_tag }} {{ 
item.name }}
{{ form.notes.label_tag }} {{ 
item.notes }}
{{ form.asset_number.label_tag }} {{ item.asset_number }}
{{ form.serial_number.label_tag }} {{ item.serial_number }}
{{ form.network_name.label_tag }} {{ item.network_name }}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e84f2b57-6e64-4801-bd0f-ff8525e93ba1n%40googlegroups.com.


Re: django-admin doesn't display choices and it's not possible to select one

2021-09-20 Thread bnmng
Hi.  I don't see anything in your code samples that would cause this.   One 
line in admin.py caused the server to stop because of the extra 
parenthesis, and the default for status should be 'r' instead of  
'refereed', but those don't cause the problem you're describing.  Maybe a 
browser issue?  Maybe there's something with a custom widget that isn't the 
samples?

On Monday, September 13, 2021 at 9:13:48 AM UTC-4 nine...@gmail.com wrote:

> Hi,
> I'm very new in Django. I'm making a cv, but I don't get select a choice 
> through the django-admin web. I've searched solutions in the community but 
> I cant't solve it.
>
> My code is:
>
> *Models.py*
> 
> class Article(models.Model):
> 
> year = models.PositiveIntegerField(
> validators=[
> MinValueValidator(1900), 
> MaxValueValidator(datetime.now().year)], null=True, 
> blank=True)
>
> title = models.CharField(max_length=200)
> author = models.ManyToManyField(Author)
> journal = models.ForeignKey(Journal, models.CASCADE)
> summary = models.TextField(max_length=1000, null=True, blank=True, 
>help_text="Brief description of the 
> article")
>
> PUB_TYPE = (
> ('r', 'refereed'),
> ('t', 'technical report'),
> ('p', 'proceeding'),
> ('b', 'book'),
> ('c', 'book chapter'),
> )
>
> status = models.CharField(max_length=1, choices=PUB_TYPE, 
> default='refereed', 
>help_text='publication type')
> 
> class Meta:
> ordering = ['year']
> 
> def get_absolute_url(self):
> return reverse('article-detail', args=[str(self.id)])
>
> def __str__(self):
> return self.title
> 
>
> *admin.py*
> """
> @admin.register(Article)
> class ArticleAdmin(admin.ModelAdmin):
> list_display = ('title', 'journal', 'year', 'status')
> list_filter = (("year", "journal")
> ordering = ('-year',)
> search_fields= ('author',)
> filter_horizontal = ('author',)
> raw_id_fields = ('journal',)
> """
> When I click in the status button (attached image), the  choices aren't 
> displayed and i can't seletc one.
> I would be very grateful for any idea.
>
> Thanks in advance,
> Maria
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3cc17c27-7c78-4f60-8a59-894711f182a1n%40googlegroups.com.


Re: django-admin doesn't display choices and it's not possible to select one

2021-09-22 Thread bnmng
Fantastic!  But now I wonder why it's not working on some of your browsers

On Wednesday, September 22, 2021 at 4:18:14 AM UTC-4 nine...@gmail.com 
wrote:

> Hi,
>
> Eureka!!! 
> Benjamin, you are right. I changed my browser and it worked.
>
> Thank for you advice.
>
> Best wishes,
> Maria
>
> On Tuesday, September 21, 2021 at 9:41:18 AM UTC+2 Mariangeles Mendoza 
> wrote:
>
>> Thank you very much!!!
>>
>> I will try other browsers. I have used Firefox and Brave.
>> No, I am not using other custom widget.
>>
>> Thanks again,
>> Maria 
>>
>> On Monday, September 20, 2021 at 1:59:25 PM UTC+2 bnmng wrote:
>>
>>> Hi.  I don't see anything in your code samples that would cause this.  
>>>  One line in admin.py caused the server to stop because of the extra 
>>> parenthesis, and the default for status should be 'r' instead of  
>>> 'refereed', but those don't cause the problem you're describing.  Maybe a 
>>> browser issue?  Maybe there's something with a custom widget that isn't the 
>>> samples?
>>>
>>> On Monday, September 13, 2021 at 9:13:48 AM UTC-4 nine...@gmail.com 
>>> wrote:
>>>
>>>> Hi,
>>>> I'm very new in Django. I'm making a cv, but I don't get select a 
>>>> choice through the django-admin web. I've searched solutions in the 
>>>> community but I cant't solve it.
>>>>
>>>> My code is:
>>>>
>>>> *Models.py*
>>>> """"
>>>> class Article(models.Model):
>>>> 
>>>> year = models.PositiveIntegerField(
>>>> validators=[
>>>> MinValueValidator(1900), 
>>>> MaxValueValidator(datetime.now().year)], null=True, 
>>>> blank=True)
>>>>
>>>> title = models.CharField(max_length=200)
>>>> author = models.ManyToManyField(Author)
>>>> journal = models.ForeignKey(Journal, models.CASCADE)
>>>> summary = models.TextField(max_length=1000, null=True, blank=True, 
>>>>help_text="Brief description of the 
>>>> article")
>>>>
>>>> PUB_TYPE = (
>>>> ('r', 'refereed'),
>>>> ('t', 'technical report'),
>>>> ('p', 'proceeding'),
>>>> ('b', 'book'),
>>>> ('c', 'book chapter'),
>>>> )
>>>>
>>>> status = models.CharField(max_length=1, choices=PUB_TYPE, 
>>>> default='refereed', 
>>>>help_text='publication type')
>>>> 
>>>> class Meta:
>>>> ordering = ['year']
>>>> 
>>>> def get_absolute_url(self):
>>>> return reverse('article-detail', args=[str(self.id)])
>>>>
>>>> def __str__(self):
>>>> return self.title
>>>> """"
>>>>
>>>> *admin.py*
>>>> """
>>>> @admin.register(Article)
>>>> class ArticleAdmin(admin.ModelAdmin):
>>>> list_display = ('title', 'journal', 'year', 'status')
>>>> list_filter = (("year", "journal")
>>>> ordering = ('-year',)
>>>> search_fields= ('author',)
>>>> filter_horizontal = ('author',)
>>>> raw_id_fields = ('journal',)
>>>> """
>>>> When I click in the status button (attached image), the  choices aren't 
>>>> displayed and i can't seletc one.
>>>> I would be very grateful for any idea.
>>>>
>>>> Thanks in advance,
>>>> Maria
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ae3983dd-1912-42f0-b68d-f996a495e67en%40googlegroups.com.


Re: Hello Everyone

2021-09-22 Thread bnmng
I'm not sure but you might be calling a function without the parentheses 
somewhere.   Seems like the function would return an object that has a 
_meta attribute, but without the parentheses the code is looking at the 
function itself, and not the object that the function returns

On Wednesday, September 15, 2021 at 12:10:11 PM UTC-4 technica...@gmail.com 
wrote:

> I'm receiving that error  I add the line from .forms import 
> CustomUserCreationForm into my views.py and it's driving me insane. I have 
> no idea how to fix this. 
>
> Exception in thread django-main-thread:
>
> Traceback (most recent call last):
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\threading.py",
>  
> line 932, in _bootstrap_inner  
>
> self.run()
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\threading.py",
>  
> line 870, in run
>
> self._target(*self._args, **self._kwargs)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py",
>  
> line 53, in wrapper
>
> fn(*args, **kwargs)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py",
>  
> line 118, in inner_run
>
> self.check(display_num_errors=True)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py",
>  
> line 392, in check
>
> all_issues = checks.run_checks(
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\registry.py",
>  
> line 70, in run_checks
>
> new_errors = check(app_configs=app_configs, databases=databases)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\urls.py",
>  
> line 13, in check_url_config
>
> return check_resolver(resolver)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\urls.py",
>  
> line 23, in check_resolver
>
> return check_method()
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 
>
> 408, in check
>
> for pattern in self.url_patterns:
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py",
>  
> line 48, in __get__
>
> res = instance.__dict__[self.name] = self.func(instance)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 
>
> 589, in url_patterns
>
> patterns = getattr(self.urlconf_module, "urlpatterns", 
> self.urlconf_module)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py",
>  
> line 48, in __get__
>
> res = instance.__dict__[self.name] = self.func(instance)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py",
>  
> line 
>
> 582, in urlconf_module
>
> return import_module(self.urlconf_name)
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py",
>  
> line 127, in import_module
>
> return _bootstrap._gcd_import(name[level:], package, level)
>
>   File "", line 1014, in _gcd_import
>
>   File "", line 991, in _find_and_load
>
>   File "", line 975, in 
> _find_and_load_unlocked
>
>   File "", line 671, in _load_unlocked
>
>   File "", line 783, in exec_module
>
>   File "", line 219, in 
> _call_with_frames_removed
>
>   File "E:\coding\django\djecommerce\django-crm\djcrm\urls.py", line 22, 
> in 
>
> from leads.views import LandingPageView, SignupView
>
>   File "E:\coding\django\djecommerce\django-crm\leads\views.py", line 6, 
> in 
>
> from .forms import LeadModelForm, LeadModelForm
>
>   File "E:\coding\django\djecommerce\django-crm\leads\forms.py", line 27, 
> in 
>
> class CustomUserCreationForm(UserCreationForm):
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\forms\models.py",
>  
> line 253, in __new__
>
> fields = fields_for_model(
>
>   File 
> "C:\Users\Technicalsmirchis\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\forms\models.py",
>  
> line 142, in fields_for_model
>
> opts = model._meta
>
> AttributeError: 'function' object has no attribute '_meta'
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dccf6

Re: Question regarding organizing models

2021-09-23 Thread bnmng
Are you saying a user can only have one company?  If a user can have more 
than one company then just define the foreign key in company.  Then there 
will automatically be query set attached to each user called company_set.  
Otherwise, you can define a OneToOneField in User.  You can create a third 
model as suggested, but I don't think you have to.  
https://docs.djangoproject.com/en/3.2/topics/db/examples/one_to_one/

On Thursday, September 23, 2021 at 10:09:39 AM UTC-4 get...@gmail.com wrote:

> create a third model and then use one-to-one relation to link the two 
> tables with the third one so that its not a deadlock between the two
>
> On Thu, Sep 23, 2021 at 7:05 PM Bhavin Shah  
> wrote:
>
>> Hello,
>>
>> Somewhat new to Django. I am trying to figure out the best way to 
>> define/organize models in Django app which have interdependent foreign 
>> keys. Simplified example below.
>>
>>
>> [image: Screenshot 2021-09-23 131449.png]
>>
>> The issue I am struggling with is the following
>>
>>1. The above example produces an error as User class is defined after 
>>Company. Reversing the order would cause the same issue with reference to 
>>Company class in User class. What is the best way to handle this scenario 
>> ? *I 
>>tried to set the created_by_id value post the User class declaration, but 
>>then the django migrations do not recognize/set the foreign key 
>> correctly.*
>>2. I also tried to split the models into multiple files as the app is 
>>expected to have several models with such interdependent foreign keys. 
>>However in that scenario, the import are causing an error due to circular 
>>references.
>>
>> Any suggestions/guidance on best way to handle such models would be very 
>> much appreciated. Thank you.
>>
>> Regards,
>>
>> Bhavin Shah
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/e279e5da-55b5-4e7f-b6a3-3e3390b2fb63n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fb6f757d-68fd-4d0c-a860-c69dfc41e42cn%40googlegroups.com.


Re: Is DATE_TIME_FORMAT in settings operationnal

2021-09-30 Thread bnmng
I haven't experimented with this yet so I'm not sure, but what about this 
note  
in https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-DATE_FORMAT

   When USE_L10N 

 is True, the locale-dictated format has higher precedence and will be 
applied instead  

On Wednesday, September 29, 2021 at 6:27:47 PM UTC-4 dilo...@gmail.com 
wrote:

> I have carefully read the documentation for the use of DATE_TIME8ROMAT in 
> settings. It is here 
> https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#date
>
> If I put the format string in the template it does format it correctly. If 
> I put the format in the settings, I get the default formatting. 
> What I am missing?
> the code is in the file included in this post.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38397f4a-f565-43d2-9330-2b8bbd758689n%40googlegroups.com.


Re: List Index out of Range

2021-10-02 Thread bnmng
Which line in your code is triggering the error?

On Saturday, October 2, 2021 at 11:07:13 AM UTC-4 eugenet...@gmail.com 
wrote:

> Good day all,
>
> I need assistance. Am trying to save data from the below form but I am 
> getting *list out of range* error
>  can someone help me to write a successful save function?
>
> here is the code I am using:
>
>
> def submit_work(request): 
> if request.method != "POST":
> return HttpResponse("Method Not Allowed")
> else:
> pillar_id=request.POST.get("pillar")
> object_id=request.POST.get("objects")
> output_id=request.POST.get("output")
> activity_id=request.POST.get("activity")
> input_list=request.POST.getlist("input[]")
> time_frame_list=request.POST.getlist("timeframe[]")
> responsible_list=request.POST.getlist("responsible[]")
> j=0
> for inp in input_list:
> wf=WORKFRAMS(pillar_id=pillar_id,object_id=object_id,output_id=output_id,
> activity_id=activity_id,
> input=inp,time_frame=time_frame_list[j],responsible=responsible_list[j])
> wf.save()
> j=j+1
> return HttpResponse("OK")
>
>
>
> [image: image.png]
>
> Regards, 
>
> *TUYIZERE Eugene*
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d69a634-0a2d-42e3-994c-5e19f88a799en%40googlegroups.com.


Re: New to Django

2021-10-03 Thread bnmng
I think you'll get a few opinions on this.  My opinion is no.  I feel the 
docs are very good but difficult to understand as a beginner.  I like 
Mozilla's into with the Local Library tutorial to get 
started https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django

On Friday, October 1, 2021 at 11:09:04 PM UTC-4 richluet...@gmail.com wrote:

> Hi, I want to learn django very well but tutorials like youtube videos, 
> books and pay for online courses are not really satisfying me that much . 
> So if I decide to learn django directly from the documentation will I learn 
> good enough to Intermediate and Advance level ?  if yes please help me with 
> an order path to follow. Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a928d80a-eaf4-495e-8e0f-abc46ba3c9a0n%40googlegroups.com.


Re: Is a Custom User Model worth the headache?

2020-02-13 Thread bnmng
Thanks for the reply.  That is a good post and I'll go along with the 
recommendation, though I still don't completely understand why adding a 
profile isn't as good as creating a custom user, and I wish I could figure 
out how to group custom users and auth groups together in the same admin 
section

Ben 

On Thursday, February 13, 2020 at 8:04:18 AM UTC-5, SikoraD wrote:
>
> Hi Ben,
>
> I'll highly recommended to read fantastic post on Will Vincent 
>  blog -> 
> https://wsvincent.com/django-tips-custom-user-model/
> His approach is much easier than one on django website and it is worth to 
> have look.
>
> Also his djangox repo on github is very useful.
>
> Best Regards
> Damian
>
>
> Hi.  
>>
>> I read the part where it's "highly recommended" to create a custom user 
>> model, but I don't see why it's worth the headache.  I found these problems:
>>
>> 1 In the admin panel, my auth groups are in a separate app from my users
>> 2 There is some disagreement out there about how apps should refer to a 
>> user model now that the user model might be custom
>> 3 A lot of features that I would add are app specific, and therefore 
>> would be better handled by app specific profiles
>> 4 There's a new entry point for possible errors and glitches
>>
>> So why do this? 
>>
>> Thanks,
>> Ben 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3210d917-e796-4b26-a316-fc3974bcfc0b%40googlegroups.com.


Re: Django - CreateView not saving form with nested formset

2020-02-23 Thread bnmng
One thing you can try for troubleshooting is an else clause to go with your 
is_valid

if education.is_valid():
education.save(commit=False)
education.instance = self.object
education.save()
else:
print('There was an error')
for err in education.errors:
  print(err)


On Sunday, February 23, 2020 at 2:01:37 AM UTC-5, Shazia Nusrat wrote:
>
> Hi,
>
> Can someone help to answer the question in link?
> Also I've been trying to get CreateView working with 5 inline formsets but 
> couldn't make it work. 
>
> Will really appreciate your help if someone can help me with working 
> example.
>
> Question: 
> https://stackoverflow.com/questions/60354976/django-createview-not-saving-form-with-nested-formset
>
> Regards,
>
> Shazia
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/86c26d31-485c-4e80-8c82-18eb4b602deb%40googlegroups.com.