Re: How and where should I put a version number in my Django project?

2016-05-03 Thread Nate Granatir
You can put the version for your project in: my_project/my_project/__init__.py (same folder as settings.py) like this: __version__ = '1.0.27' Then your project acts as a python module, and you can refer to the version number, for instance in your settings.py, as: GRAPPELLI_ADMIN_TITLE = 'My Pr

Re: Beginner question regarding virtualenv

2016-06-24 Thread Nate Granatir
I've found that virtualenvs are definitely worth the time to set up, there will be a time down the road when you need to have two different versions of the same package. Also, I'd strongly recommend storing the project's dependencies in a requirements.txt file. I have a terrible memory and would

Re: Django template iterating through two dictionaries/variables

2016-08-30 Thread Nate Granatir
You could also just join the dicts before passing them to the template. It looks like it's relatively straightforward (scores is just a list that contains dicts of a 'Number' and a 'score', right?) Then you could turn scores into a dict, assuming Numbers are unique: scores_new = {score['Number'

Re: Newbie to Novice – Using Admin DateTime Picker in your Form

2016-09-19 Thread Nate Granatir
I just installed Django Daterange Filter 1.3.0 (https://github.com/DXist/django-daterange-filter) on a Django 1.9 project. Took a little CSS fiddling to get it to display properly with Grappelli, but other than that it worked like a charm. Nate On Thursday, March 19, 2009 at 8:37:56 AM UTC-5,

Re: Newbie to Novice – Using Admin DateTime Picker in your Form

2016-09-19 Thread Nate Granatir
Just realized this thread was not necessarily about filters for the admin; in the case of using custom forms/views Django daterange filter may not be a good option. On Thursday, March 19, 2009 at 8:37:56 AM UTC-5, Paul Nema wrote: > > I've noticed many people new to Django (and sometimes also ne

Re: Negative User ID's

2016-11-04 Thread Nate Granatir
Or why not just assign certain Users to certain Groups? That seems like a much more clean and simple way of handling the problem. You'd be able to easily filter either set of users, and it would require very little custom code. Plus, doing something like assigning negative IDs disguises what yo

Re: SQLAchemy

2016-11-04 Thread Nate Granatir
Yes, why are you using SQLAlchemy instead of Django's built-in ORM? I don't see any reason to even attempt this unless you need to perform operations outside the context of Django. On Wednesday, November 2, 2016 at 2:09:18 AM UTC-5, pradam.programming wrote: > > hi, > I am new to SqlAchemy.My

Re: Annotate a List of Values

2016-11-18 Thread Nate Granatir
As demonstrated here: https://docs.djangoproject.com/en/1.10/topics/db/examples/many_to_many/ If you have a ManyToMany relationship set up in your models, say: class SerialNumber(models.Model): serial = models.CharField(max_length=50) class Item(models.Model): item_name = models.CharFi

inline parent value

2016-12-10 Thread Nate Granatir
You should be able to customize the queryset of any form by overriding it in the init method of the form. In this case, it's a little trickier because you'll need a custom admin and custom form for the inline. I haven't been able to test this, but I think you'll need to do the following. In fo

Re: How to design High Scalability architecture with Django in cost effective fashion

2017-04-03 Thread Nate Granatir
I am also not even close to being an expert on this topic, but I do know that it's super easy to deploy a Django app on Heroku, which will get you scalable app deployment and Postgres dbs with very little upfront effort. https://devcenter.heroku.com/articles/deploying-python Nate On Sunday, Apr

Re: Setting up an App and getting an import error

2017-04-07 Thread Nate Granatir
I may be speaking a bit out of my depth here, but I wonder if it's maybe because you haven't created __init__.py files in the directories? I believe Django (well, Python), requires an empty __init__.py file in directories when loading them as modules: https://docs.python.org/3/tutorial/modules.h

Apply default filters in admin

2017-04-24 Thread Nate Granatir
In my app I have admin filters for a field called "language" - language is a field in several of my models - and I've created them custom, inheriting from SimpleListFilter, so that I can apply a default of English when none has yet been specified. This works almost perfectly - the only problem i

Re: Apply default filters in admin

2017-04-24 Thread Nate Granatir
: > q = request.GET.copy() > q.setdefault('lang', 'en') > return redirect('%s?%s' % (request.path, q.urlencode())) > > > > > On Monday, April 24, 2017 at 7:12:18 PM UTC+3, Nate Granatir wrote: >> >> In my app I have admin

Re: Apply default filters in admin

2017-04-27 Thread Nate Granatir
redirect('%s?%s' % (request.path, q.urlencode())) > return super(MyModelAdmin, self).changelist_view( > request, extra_context=extra_context, > ) > > > > > On Tuesday, April 25, 2017 at 2:08:33 AM UTC+3, Nate Granatir wrote: >> >>