RE: trouble with setting static for img and css

2017-05-11 Thread Matthew Pava
Typically, we set it to "/static/". STATIC_URL = "/static/" Don't forget to run your collectstatic management command. python manage.py collectstatic -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of johnf Sent: Thursday, May 11, 2

RE: append language-code tot variable name

2017-05-23 Thread Matthew Pava
Have you considered internationalization and localization as an alternative to what you are doing? https://docs.djangoproject.com/en/1.11/topics/i18n/ To do what you are doing, you would need to do it in the view function, something like this: context[‘title’] = getattr(artobject, “%s_%s” % (tit

RE: count from multiple tables in a single query?

2017-05-31 Thread Matthew Pava
Hi Abraham, If the models are related, you can use double underscore notation with the Count aggregate function. If the models are unrelated, then I’m fairly certain that you can only use separate queries to get your results. From: 'Abraham Varricatt' via Django users [mailto:django-users@goog

ModelFormset Into InlineFormset

2017-05-31 Thread Matthew Pava
I have a class CustomFormSet that inherits from BaseModelFormSet. I would like to have another formset class that does everything CustomFormSet does but instead inherits from BaseInlineFormSet. What is the best pythonic/Django way of doing that? -- You received this message because you are s

RE: ModelFormset Into InlineFormset

2017-06-01 Thread Matthew Pava
@googlegroups.com] On Behalf Of James Schneider Sent: Wednesday, May 31, 2017 6:24 PM To: django-users@googlegroups.com Subject: Re: ModelFormset Into InlineFormset On Wed, May 31, 2017 at 3:13 PM, Matthew Pava mailto:matthew.p...@iss.com>> wrote: I have a class CustomFormSet that inherit

Inconsistency of clean method

2017-06-02 Thread Matthew Pava
I have been working with Django for several years and just discovered this gem in the documentation (emphasis mine): https://docs.djangoproject.com/en/1.11/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other "If your form inherits another that doesn't return a cleaned_d

RE: Install Django

2017-06-07 Thread Matthew Pava
You need to activate your virtual environment and then run “pip install django.” D:/Project/Pyton/lalala/activate.bat pip install django From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of sadri ashari Sent: Wednesday, June 7, 2017 2:34 AM To: Django users Subj

RE: ordering queries based on most upvotes

2017-06-14 Thread Matthew Pava
It is difficult to follow your formatting, so I updated it below. I would always avoid using GenericForeignKey(). That’s my own personal preference, but it doesn’t even seem like you need it in your situation. You could just have a ForeignKey or ManyToMany directly to Activity. Read more abou

RE: How to get a list of queryset selected fields

2017-06-15 Thread Matthew Pava
You may be looking for values. MyModel.objects.all().values() returns a QuerySet list of dictionaries with the field names as the keys. You can specify which specific fields you want to return by passing them as arguments to values(). MyModel.objects.all().values('id', 'name') Then you can use th

RE: How to get a list of queryset selected fields

2017-06-15 Thread Matthew Pava
ribute of .keys(). -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Todor Velichkov Sent: Thursday, June 15, 2017 12:36 PM To: Django users Subject: RE: How to get a list of queryset selected fields Hello, Matthew Pava, thank you for your a

RE: how to combine views in one template

2017-06-16 Thread Matthew Pava
Hi Mark, You would pass the form in the context of the template in the view. You can pass pretty much anything to a template through the context. def builddetails(request, id): build = Build.objects.get(pk=id) form = BuildForm(request.POST or None) if form.is_valid(): form

RE: Internet Explorer question

2017-06-16 Thread Matthew Pava
The only Microsoft-supported version of IE is version 11. And it seems to work just fine for me in Django Admin 1.10. If you users aren’t using version 11, I would start there. Then check the computer; maybe the user needs to delete some temporary files. From: django-users@googlegroups.com [

RE: facing an error from many hours

2017-06-23 Thread Matthew Pava
I’ve had this problem a few times. First, try updating PyCharm. I find when I click on my runserver icon, I just keep clicking it until it works. Not much of a fix, but it has worked for me. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of khaleeq rehma

Form Error List

2017-06-23 Thread Matthew Pava
I was just running into an issue where I append an error to _non_form_errors in a formset. (Maybe I should re-think that.) Anyway, it happens in the clean method, and I end up calling the clean method twice. Lo and behold, the error message gets appended twice and the user sees a duplicate err

RE: Avoid primary key in Django models.py

2017-08-04 Thread Matthew Pava
You can’t. You can change what field is the primary key, but you can’t remove the primary key. Just specify primary_key=True on the field you would like to make your primary key. >From the docs: Each model requires exactly one field to have primary_key=True

Template Rendering Django 1.11

2017-08-04 Thread Matthew Pava
I finally made the leap to Django 1.11 from 1.10. I thought that I needed to use the new Subquery, but it turned out that I was able to solve my problem without using it. Good news for sure! However, I have noticed that my forms are loading more slowly. We discovered that when we were using c

RE: Django Python OSError No such file or directory but file exists

2017-08-07 Thread Matthew Pava
That’s a great idea. How do you do that programmatically? From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of "? ? (roboslone)" Sent: Monday, August 7, 2017 4:32 PM To: django-users@googlegroups.com Subject: Re: Django Python OSError No such fi

RE: Tutorial writing views help

2017-08-14 Thread Matthew Pava
And are you navigating to http://127.0.0.1:8000/polls/ ? I don’t think you should have anything at http://127.0.0.1:8000/ or so it seems. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Kareem Hart Sent: Monday, August 14, 2017 4:05 PM To: Django users Sub

RE: Template Rendering Django 1.11

2017-08-16 Thread Matthew Pava
be able to modify it for our requirements, and it is no longer the same app. From: Tim Graham [mailto:timogra...@gmail.com] Sent: Monday, August 7, 2017 4:02 PM To: django-users@googlegroups.com Cc: Matthew Pava Subject: Re: Template Rendering Django 1.11 You'll have to profile and see w

class Meta(object)

2017-08-28 Thread Matthew Pava
Should our Meta classes inherit from object? I just did a code inspection and got that message a few times; it never occurred to me to do that before, and even the Django documentation doesn't have Meta inherit from object. What is the best practice, especially with Python 3? -- You received

RE: Annotating a query with comparison result e.g. F('foo') == F('bar')

2017-09-01 Thread Matthew Pava
I would approach your problem differently, though I don’t see why Django shouldn’t support such a construct in the future. I would use a Case…When construct. Status.objects.annotate(mine=Case(When(user_id=7,then=True), default=False, output_field=BooleanField()).order_by(‘-mine’) From: django-u

Migration Woes: TypeError: int() argument must be a string... on ForeignKeys

2017-09-12 Thread Matthew Pava
I'm trying to alter my foreign keys on my audit log models to allow for null. Django creates a new migration file, with an operation something like below: migrations.AlterField( model_name='checklistauditlogentry', name='usage', field=models.ForeignKey

RE: Migration Woes: TypeError: int() argument must be a string... on ForeignKeys

2017-09-13 Thread Matthew Pava
@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Matthew Pava Sent: Tuesday, September 12, 2017 4:09 PM To: django-users@googlegroups.com Subject: Migration Woes: TypeError: int() argument must be a string... on ForeignKeys I’m trying to alter my foreign keys on my audit log models to allow

RE: FROM ONLY in Postgres back-end

2017-09-13 Thread Matthew Pava
If you want to do auditing of the database, I would look at packages available for Django. This is the first I've read about "temporal tables," and my first impression is that of grave concern. Django-reversion is a popular package: https://github.com/etianen/django-reversion -Original Mes

RE: single queryset from multiple tables

2017-09-18 Thread Matthew Pava
I'm assuming that Model_A and Model_B have some similar columns if you are going to be showing them as an index view. It would seem to me that you need to reconsider your model design. Perhaps you can pull out what is common between them and create another model that they both inherit from or

RE: Data_upload_max_number_fields increase greater then 1000 in Django framework?

2017-09-19 Thread Matthew Pava
https://docs.djangoproject.com/en/1.10/_modules/django/utils/http/ DATA_UPLOAD_MAX_NUMBER_FIELDS = None From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Kusum Kumari Sent: Tuesday, September 19, 2017 6:26 AM To: Django users Subject: Data_upload_max_number_

RE: CSRF and API Calls

2017-09-22 Thread Matthew Pava
Do you have access to the Django backend code? You could disable CSRF validation by applying the @csrf_exempt decorator to the corresponding view functions. Maybe you could create a view that returns only the CSRF token (through AJAX?) that you can utilize as needed? From: django-users@googlegro

RE: There is any way to prevent cascade delete on FK field, without using signal?

2017-10-03 Thread Matthew Pava
Have you checked the arguments for on_delete on ForeignKey? https://docs.djangoproject.com/en/1.11/ref/models/fields/#arguments There’s models.SET_NULL, models.SET_DEFAULT, models.DO_NOTHING, etc… If you need to prevent someone from deleting something, you should use view permissions. From: dj

RE: There is any way to prevent cascade delete on FK field, without using signal?

2017-10-04 Thread Matthew Pava
Hi Felipe, I found this question on Stack Overflow, which seems to provide some insight on how to accomplish what you want. https://stackoverflow.com/questions/4825815/prevent-delete-in-django-model Basically, you need to override the delete method on the model and on the QuerySet of the model’s

RE: Bulk update instances to different values

2017-10-05 Thread Matthew Pava
Perhaps you will find this package helpful: https://github.com/aykut/django-bulk-update From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of David Foster Sent: Wednesday, October 4, 2017 10:51 PM To: Django users Subject: Bulk update instances to different valu

RE: DATA_UPLOAD_MAX_NUMBER_FIELDS exceeded when not conducting a mass event re ticket #26810

2017-10-12 Thread Matthew Pava
You may just want to set it to None, but check out the description in documentation. https://docs.djangoproject.com/en/1.11/ref/settings/#data-upload-max-number-fields -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Mike Dewhirs

Queryset Union

2017-10-17 Thread Matthew Pava
Hi fellow users, I came across a situation where I needed to annotate a union-all query. Django's ORM is so powerful, and it has those features separately, but it cannot seem to handle annotating a union-all query. I was able to solve my problem by using two views inside PostgreSQL. I created

Changing name of file in FileField field

2020-06-09 Thread Matthew Pava
Good day, I have been struggling with this issue for weeks, and I can't figure out what I'm doing wrong. I have a model with a FileField with a custom upload_to function. It seems to work fine when I'm doing runserver. Problems arise during my tests. My assertion error fails: AssertionError: 'R

Exception During Testing on Windows, Python 3.8

2020-06-11 Thread Matthew Pava
I continue to receive the following exception error at every single one of my tests. I'm running Python 3.8.2 on Windows 10. Exception happened during processing of request from ('127.0.0.1', 54962) Traceback (most recent call last): File "c:\program fil

send_mail not filling mail.outbox in certain circumstance

2020-07-08 Thread Matthew Pava
Good day, I'm writing a functional test for checking that an email was sent after a record was revised in my project. I placed a print statement to verify that the send_mail function was called within the view that it is called in, and it prints it out at the appropriate time. However, when I ch

Re: send_mail not filling mail.outbox in certain circumstance

2020-07-08 Thread Matthew Pava
:55:21 AM UTC-5, Matthew Pava wrote: > > Good day, > I'm writing a functional test for checking that an email was sent after a > record was revised in my project. I placed a print statement to verify that > the send_mail function was called within the view that it is called in,

RE: Newbie : Best data archive strategy

2018-06-12 Thread Matthew Pava
I think what you’re really looking for is an audit log. There are some Django packages available that do that automatically. You might find this one quite helpful, called Django Reversion: https://github.com/etianen/django-reversion From: django-users@googlegroups.com [mailto:django-users@goog

RE: Newbie : Best data archive strategy

2018-06-12 Thread Matthew Pava
1:17 PM To: Django users Subject: Re: Newbie : Best data archive strategy Thanks Matthew for your response. I looked at Reversion. If I understand correctly what it did, it duplicate each transaction on internal database ? Le mardi 12 juin 2018 20:01:02 UTC+2, Matthew Pava a écrit : I think what

RE: Nested for loops in templates

2018-06-13 Thread Matthew Pava
field is a string – a name of a field, field is not actually an attribute of row. You’ll need a template tag to get the attribute named field from row. This StackOverflow question may help you: https://stackoverflow.com/questions/844746/performing-a-getattr-style-lookup-in-a-django-template?utm_m

RE: How to include a Where clause for each query on django?

2018-06-14 Thread Matthew Pava
Just create a custom manager and pass in the current user to it. https://docs.djangoproject.com/en/2.0/topics/db/managers/ class MyCustomManager(models.Manager): def with_current_user(current_user): return self.filter(user=current_user) In y our model: class MyMod

RE: Nested for loops in templates

2018-06-15 Thread Matthew Pava
lly from a string name""" if hasattr(value, str(arg)): return getattr(value, arg) else return "" thanks, Mikkel torsdag den 14. juni 2018 kl. 00.19.24 UTC+2 skrev Matthew Pava: field is a string – a name of a field, field is not actually an attribute of

RE: Help with context_processor

2018-06-20 Thread Matthew Pava
Well, you can access a dictionary like a list using these: items.keys(), template: for k in items.keys items.values(), template: for v in items.values items.items(), template: for k, v in items.items From: django-users@googlegroups.com [mailto:dja

RE: How to fill latitude and longitude values from an existing location field in Django+Python?

2018-06-21 Thread Matthew Pava
Based on the information of that project, it does not support Django passed version 1.10. What version are you using? Saving of the location should be automatic based on my understanding of that package. You may want to contact the author of that package to get more help. From: django-users@goo

RE: help

2018-07-06 Thread Matthew Pava
You need to add the on_delete keyword argument to the ForeignKey. https://docs.djangoproject.com/en/2.0/ref/models/fields/#django.db.models.ForeignKey.on_delete From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Avi gehlot Sent: Friday, July 6, 2018 10:16 AM

RE: Configuring Remote Existing DB through RDS

2018-07-10 Thread Matthew Pava
One thing that stands out to me is that the exception message indicates that it is looking for “detectiondata_dev” instead of “detectiondata-dev”. Also, did you run migrations? From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of acka...@ucsd.edu Sent: Monday,

RE: Pass empty slug field in urls

2018-07-12 Thread Matthew Pava
The error is due to not having a slug. You’ll have to create a URL path to /restaurants/ if you want to allow an empty slug. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Can Hicabi Tartanoglu Sent: Thursday, July 12, 2018 5:06 AM To: Django users Subje

RE: About UserCreationForm

2018-07-12 Thread Matthew Pava
Because it’s actually django.contrib.auth.forms …with an s. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of abhishek dadhich Sent: Thursday, July 12, 2018 1:43 PM To: Django users Subject: About UserCreationForm I want to use UserCreationForm but I can't

RE: help with get_form_kwargs

2018-07-16 Thread Matthew Pava
I would alter user input in the clean methods. https://docs.djangoproject.com/en/2.0/ref/forms/validation/ From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of clavierpla...@gmail.com Sent: Monday, July 16, 2018 10:28 AM To: Django users Subject: help with get_

RE: help with get_form_kwargs

2018-07-16 Thread Matthew Pava
um = self.cleaned_data['item'] actual_item = Item.objects.get(item_number=item_num) return actual_item.id I'm sure I've overlooked something simple, but meanwhile I'm looking for any kind of workaround. But thank you for the suggestion! I wish I knew how to imp

RE: trying to learn custom validators

2018-07-16 Thread Matthew Pava
What I would do in that situation is add a custom field to the model form that holds the item number. Then, in the save method, convert that to the Item object. class AddItem(forms.ModelForm): item_number = IntegerField() class Meta: model = ItemsTestCollection fields

RE: Django foreign-key cannot assign must be a instance

2018-07-18 Thread Matthew Pava
> Also when creating my models I use "id = models.AutoField(primary_key=True)" > for my ID field. This way Django will Auto generate an ID for each record. This is unnecessary. Django does this automatically. https://docs.djangoproject.com/en/2.0/topics/db/models/#automatic-primary-key-fields

RE: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread Matthew Pava
It looks like you have a typo: urlpatterns = [ # ex: /polls/ path('', views.IndexView.as_view(), name='index'), # ex: /polls/5/ # the 'name' value as called by the {% url %} template tag path('/', views.DetailView.as_view(), name='detail'), # ex: /polls/5/results/ path(

RE: Validating count + property of a Many2Many with a through table

2018-07-31 Thread Matthew Pava
Hi Sanjay, You may want to try signals. https://docs.djangoproject.com/en/2.0/topics/signals/ -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Sanjay Bhangar Sent: Tuesday, July 31, 2018 1:09 PM To: django-users@googlegroups.com S

RE: External DB layout, two column as PK, modification not possible

2018-08-01 Thread Matthew Pava
I did some Google searches for you. There’s still an open ticket for it, open for the past 12 years: https://code.djangoproject.com/ticket/373 There’s plenty of people asking the same question. Here’s one on Stack Overflow: https://stackoverflow.com/questions/16800375/how-can-set-two-field-prima

RE: i want to save is_staff value true in db but not save in database

2018-08-02 Thread Matthew Pava
You’re adding an attribute (is_staff) to the form and then saving the form, but no method is doing anything with that attribute. When you save a model form, it will return the instance of the model. You can then proceed to change that model, and save it again. if form.is_valid():

RE: trouble adding variables to URLs in templates... seems some characters get cut out like "?"

2018-08-02 Thread Matthew Pava
I would verify that the view actually assigns to the template variable what you are expecting it to be assigned to. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Christian Seberino Sent: Thursday, August 2, 2018 3:36 PM To: Django users Subject: trouble

RE: Django ORM aggregate Sum function on foreign key

2018-08-06 Thread Matthew Pava
You need to specify the field of the value in your ORM statement. I don’t know what your field name is, but this assumes that it is “value”: aggregate(Sum(‘payment__value’)) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Gerald Brown Sent: Monday, August

RE: Upgrading from Django 1.7: render_to_response and context_instance

2018-08-08 Thread Matthew Pava
If you are simply adding something to most every request, I would add a context processor in the TEMPLATE settings. Check out https://docs.djangoproject.com/en/2.1/topics/templates/#context-processors In this example, I have an app called general. Within that is a py file called context_proce

RE: django models

2018-08-08 Thread Matthew Pava
Well, you could generate a SECRET KEY here: https://www.miniwebtool.com/django-secret-key-generator/ Then in your settings.py file you need to add this line: SECRET_KEY = “[insert secret key here]” https://docs.djangoproject.com/en/dev/ref/settings/#secret-key From: django-users@googlegroups.co

RE: Unexpected behavior with icontains in query filter

2018-08-10 Thread Matthew Pava
I’m fascinated by this problem. Try this workaround. https://docs.djangoproject.com/en/2.0/ref/models/database-functions/#lower Register the lookup Lower like so: CharField.register_lookup(Lower, "lower") Then use the contains lookup. doctor.objects.filter(name__lower__contains="joel") From: dj

RE: Select2 default value

2018-08-13 Thread Matthew Pava
In Django forms, it’s called an initial value instead of a default value. https://docs.djangoproject.com/en/2.1/ref/forms/api/#django.forms.Form.initial From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of matteo gassend Sent: Monday, August 13, 2018 9:49 AM T

RE: Select2 default value

2018-08-13 Thread Matthew Pava
Yes… From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of matteo gassend Sent: Monday, August 13, 2018 10:10 AM To: Django users Subject: Re: Select2 default value Even for a Modelform? Il giorno lunedì 13 agosto 2018 17:08:35 UTC+2, Matthew Pava ha scritto

RE: GROUP BY

2018-08-13 Thread Matthew Pava
You need to include “ownProduction” in your values list prior to the annotation. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Mikkel Kromann Sent: Monday, August 13, 2018 3:22 PM To: Django users Subject: GROUP BY I'm trying to sum the field "ownProduc

RE: GROUP BY

2018-08-14 Thread Matthew Pava
.values('week','market__name', 'contracted') ) for contract_row in contract_query: contract_sum = contract_row.contracted I am somewhat confused by this ... Mikkel mandag den 13. august 2018 kl. 22.24.48 UTC+

RE: GROUP BY

2018-08-14 Thread Matthew Pava
;contracted". It seems to me that having the values() statement after the annotation deletes the annotation- is that correct? And is that intended behavior? If so, how can I then group by the week function of a datefield? Or is there something that I got completely wrong? thanks + c

RE: Compiling django filters into a variable and executing it at runtime?

2018-08-15 Thread Matthew Pava
I would take advantage of keyword arguments and dictionary expansion notation. I would use something like this: fields = ['cstid', 'age', 'gender', 'city'] search_query_and = {} search_query_or = Q() for f in fields: if request.POST.get(f): search_query_and[f"{f}__contains"] = request.

RE: problems with order by month

2018-08-20 Thread Matthew Pava
Try this: cardio = Alumno.objects.filter(fechanacimiento__month=timezone.now().month) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Osvaldo Ruso Olea Sent: Monday, August 20, 2018 2:58 PM To: Django users Subject: problems with order by month Hi how are

RE: problems with order by month

2018-08-21 Thread Matthew Pava
ardio': cardio} return render (request, 'cardio.html', context) What I can not do is sort the dates from lowest to highest, Thank you very much El lun., 20 ago. 2018 a las 19:03, Matthew Pava (mailto:matthew.p...@iss.com>>) escribió: Try this: cardio = Alumno.objects.fil

RE: Django performance issue that's troubling

2018-08-24 Thread Matthew Pava
You can keep the field, but change its widget to a HiddenInput. https://stackoverflow.com/questions/6862250/change-a-django-form-field-to-a-hidden-field From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Vijay Khemlani Sent: Friday, August 24, 2018 12:59 PM

RE: Django performance issue that's troubling

2018-08-24 Thread Matthew Pava
as to fill in all possible values - 37K - so it takes multiple seconds. Vijay, I’ll try your suggestion. Thanks much, Jim On Aug 24, 2018, at 11:01 AM, Matthew Pava mailto:matthew.p...@iss.com>> wrote: You can keep the field, but change its widget to a HiddenInput. https://stacko

RE: ArrayAgg ordering not working?

2018-08-24 Thread Matthew Pava
The fix hasn’t been released yet. It’s in the master branch, and it was committed on June 28. If I understand it correctly, it should pop up in the next release. https://github.com/django/django/pull/7604 From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf O

RE: "to" argument must be a list or tuple

2018-08-27 Thread Matthew Pava
Make it a list or tuple by surrounding it in brackets or parentheses. [user.email] or (user.email, ) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Damandeep Singh Sent: Monday, August 27, 2018 6:08 AM To: Django users Subject: "to" argument must be a l

RE: Printing model fields organized by category

2018-08-27 Thread Matthew Pava
wever, this just prints "There is no equipment in the database". Am I missing something? I will try to experiment a little more. On Monday, August 27, 2018 at 9:52:56 AM UTC-4, Matthew Pava wrote: Hi Jay, Firstly, I would avoid calling a model “Model.” Maybe “Product” would be bet

RE: Printing model fields organized by category

2018-08-27 Thread Matthew Pava
nRequiredMixin,generic.ListView): """Generic class-based view listing books on loan to current user.""" model = BookInstance template_name ='catalog/bookinstance_list_borrowed_user.html' paginate_by = 10 def get_queryset(self): return Boo

RE: Foreign key auto-created column position in table

2018-08-28 Thread Matthew Pava
You can probably just modify the migrations file after it is generated. Just move the statements around. I haven’t tested it myself. Saying that, why is the order of columns important to you? We don’t typically worry about the order of columns when working with databases. From: django-users@g

RE: How to get multi form initial data?

2018-09-11 Thread Matthew Pava
You are using a dictionary as your form_class. It should only be one form, as far as I know. I am quite interested to learn how you got the form working by specifying a dictionary. Please review documentation: https://docs.djangoproject.com/en/2.1/topics/class-based-views/generic-editing/ And

RE: Kerberos authent implementation

2018-09-13 Thread Matthew Pava
What would be the motivation for Kerberos authentication? Why not just use LDAP authentication? Just wondering for my own edification. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Benjamin SOULAS Sent: Thursday, September 13, 2018 9:20 AM To: Django u

RE: Kerberos authent implementation

2018-09-13 Thread Matthew Pava
Hi Benjamin, If it’s any help to you, we use LDAP through Active Directory for our authentication system. We use the django-auth-ldap package. It’s been a little tricky with the upgrade to Python 3/Django 2, but it’s quite manageable. Unfortunately, I can’t help you much with Kerberos authentic

RE: Chaining Q objects

2018-09-19 Thread Matthew Pava
I’m not entirely sure if the error is from your Q chain, but something I would try is to replace “[:1].get()” with “.first()”. wm = Boat.objects.filter(name=x).filter( f ).first() From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of MikeKJ Sent: Wednesday, Sep

Re: Error at OneToOneField in models while creating new models class

2018-09-22 Thread Matthew Pava
Did you try running your migrations? Get Outlook for Android On Sat, Sep 22, 2018 at 5:07 AM -0500, "Srinivas Gadi" mailto:srini@gmail.com>> wrote: Adding more and complete details: I am facing below error while creating a new model class. the error pops up only at

RE: Multiple annotations in one query

2018-09-24 Thread Matthew Pava
Hi David, Performing multiple annotations on a queryset is not the same as combining multiple aggregations. Saying that, if you truly are getting wrong results, you could try using the Window functions or the Subquery object. https://docs.djangoproject.com/en/2.1/ref/models/database-functions/#wi

RE: django raw sql query does not return data

2018-09-26 Thread Matthew Pava
Listen to the error message. Include the primary key in the queryset. You can use any field and alias it as “id” if you need to trick the system. Although, couldn’t that raw query use the ORM in a better way? Post.objects.annotate(uno=Count(‘title’), published_date_date=Cast(‘published_date’, D

Running Signal when Related Field is Updated

2018-09-26 Thread Matthew Pava
I have a similar set up to this (simplified): class Transaction(models.Model): sns = models.ManyToManyField(SN, related_name="transactions", blank=True) qty = models.FloatField() part = models.ForeignKey(Part, on_delete=models.CASCADE) class InventoryTransaction(models.Model): tr

RE: db_index=True not creating indexes

2018-10-05 Thread Matthew Pava
Hi, I’m using Django 2.0 and PostgreSQL 9.something, but my tables do have indexes. Did you run the makemigrations command before running the migrate command? Also, you can modify the database that Django uses however you want with some caveats. Anyway, you can add views and modify columns and

RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
Hi Michel, The error states that there is no such table finance_transactions with an s on the end. Maybe you could show us your view code, but that would be the place that I would start at. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Michel Lavoie S

RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
table name. But I'm sure that it doesn't come from my views.py, this error appeared after upgrading to 2.1. My app's code is on GitHub: https://github.com/miek770/huitcent/tree/master/finance Thanks, Michel On Mon, Oct 8, 2018, 09:46 Matthew Pava, mailto:matthew.p...@iss.com>

RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
It almost seems like your database is corrupt. Did you run migrations before running the server? From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Michel Lavoie Sent: Monday, October 8, 2018 1:15 PM To: django-users@googlegroups.com Subject: Re: "No such ta

RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
I would submit a ticket for that issue. Also, instead of using string functions to solve your problem, I would use the ExtractYear function. Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year')) From: django-users@googlegroups.com [mailto:django-users@

RE: Alternatives to using __contains?

2018-10-09 Thread Matthew Pava
No. Usually, you would try to keep all of your filtering in the managers module, and then you would be able to limit your refactoring of filters in that file. You could try using *args and **kwargs syntax, but that would make it difficult to maintain. I suppose you could functions in SQLAlchemy,

RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. On Tuesday, October 9, 2018 at 6:45:32 AM UTC-7, Matthew Pava wrote: I would submit a ticket for that issue. Also, instead of using string functions to solve your problem, I would

RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
nd the inner workings of casting and filtering between Django and Postgres. Thanks again for your help On Tuesday, October 9, 2018 at 9:48:22 AM UTC-7, Matthew Pava wrote: Oh, I see. Then just use Cast, or the output_field argument . Conference.objects.annotate(year=ExtractYear('start_date',

RE: FormModel not validating the fields

2018-10-16 Thread Matthew Pava
It’s difficult to tell with your spacing in the email. The function needs to be inside the class, not outside. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of faizan.fa...@gslab.com Sent: Tuesday, October 16, 2018 4:34 AM To: Django users Subject: FormMod

RE: Need help for sql stored proc

2018-10-17 Thread Matthew Pava
https://docs.djangoproject.com/en/2.1/topics/db/sql/#calling-stored-procedures From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Gurmeet Kaur Sent: Wednesday, October 17, 2018 11:06 AM To: django-users@googlegroups.com Subject: Need help for sql stored proc

RE: Creating seperate unique ids within the same table

2018-10-17 Thread Matthew Pava
A number is a number, and we don’t need to attach meaning to it. Why do you need to have continuous ids unique to each clinic? As a developer, I would object to anyone forcing such a requirement. If they insisted, then I would add a property that is calculated each time based on the count of p

RE: Creating seperate unique ids within the same table

2018-10-18 Thread Matthew Pava
only one patient id but many checkin ids. > > What can be a good approach to solve this? Should I perhaps create another > table just to store the last patient id issued to each clinic? > > > > > On Wed, 17 Oct 2018 at 21:49, Matthew Pava wrote: >> >> A

RE: Creating seperate unique ids within the same table

2018-10-18 Thread Matthew Pava
t 2018 at 19:01, Matthew Pava wrote: > > Hi Dr Joel, > Each patient already has a unique number--the id or pk of the > model--regardless of what clinic the patient goes to. I even recommend > maintaining this structure. Any other numbers you add to the ID are just > noise. Be

RE: How can I implement built in signals, for my app?

2018-10-22 Thread Matthew Pava
You may want to look at this middleware package that will automatically audit user logins. https://github.com/muccg/django-useraudit Also, in using AppConfigs, avoid using default_app_config as stated here: https://docs.djangoproject.com/en/2.1/ref/applications/#configuring-applications "New appl

RE: Creating seperate unique ids within the same table

2018-10-22 Thread Matthew Pava
I am curious why you think it is anti-practice to expose primary keys for user-visible purposes. My URLs all have the PK to the object in them, and any advanced user would be able to “reverse engineer” a URL if they guess the PK of an object—and that’s okay. Even Django tutorials suggest using t

RE: Creating seperate unique ids within the same table

2018-10-22 Thread Matthew Pava
lf Of Andrew Pinkham Sent: Monday, October 22, 2018 11:51 AM To: django-users@googlegroups.com Subject: Re: Creating seperate unique ids within the same table On Oct 22, 2018, at 12:29, Matthew Pava wrote: > I am curious why you think it is anti-practice to expose primary keys for > user-visib

RE: There's a complete CRUD app for django, like Admin?

2018-10-23 Thread Matthew Pava
You might want to have a look at YourLabs CRUDLFAP+: https://yourlabs.io/oss/crudlfap From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Fellipe Henrique Sent: Tuesday, October 23, 2018 7:02 AM To: Django Users Subject: There's a complete CRUD app for django,

<    1   2   3   4   >