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

Re: When you app depends on a custom user model

2021-10-11 Thread bnmng
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(). >>

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, 20

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 b

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 wr

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

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

Re: def post in ListView

2021-11-24 Thread bnmng
lit 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

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 recei

Re: dotenv - django-environ - etc

2021-12-30 Thread bnmng
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: >> >>>

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 wher

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.po

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 c

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

2022-01-26 Thread bnmng
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

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 Ma

Re: relations

2022-01-26 Thread bnmng
_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

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 V

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

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_d

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?

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

2021-09-22 Thread bnmng
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

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, Sep

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 thir

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 hig

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 success

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, 2

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 secti

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')