Re: Accessing Models After get_model()

2014-12-22 Thread Collin Anderson
Hi, The model name is hidden in model.__name__ or model._meta.model_name, and you can't access attributes starting with underscore in templates. This might work: from django.db.models import get_app, get_models def index(request): app = get_app('sampledb') modeldict =

Re: makemigrate adds multiple migrations.AddField for same model (django 1.7.1)

2014-12-22 Thread Collin Anderson
Hi, You're just using one database? Are all 6 ALTER statements identical? Collin On Sunday, December 21, 2014 5:27:06 PM UTC-6, pjotr wrote: > > Just realized the subject was wrong, it should be *makemigrations , not > makemigrate* > > On Sunday, December 21, 2014 8:36:29 PM UTC+1, pjotr

Re: Model form with optional fields issue

2014-12-22 Thread James Schneider
That seems like a bit of a broad brush stroke against Django. Have you looked at the Django REST Framework module? It can often utilize your existing views, and has support for partial updates. http://www.django-rest-framework.org/api-guide/serializers/#partial-updates Django is primarily used

Re: How to Display the number of active users in Django Site with IP address

2014-12-22 Thread Collin Anderson
Hi, Something like this might be a start: class UserIP(models.Model): user = models.ForeignKey(User) ip = models.GenericIPAddressField() last_seen = models.DateTimeField(auto_now=True) class Middleware(pass): def process_response(request, response): if request.user: #

Re: Random row

2014-12-22 Thread Collin Anderson
Hi, Are you sure you saved your code? There's a len() in your traceback that isn't in your code. Collin On Saturday, December 20, 2014 3:50:11 PM UTC-6, Dariusz Mysior wrote: > > I change it on > > import csv, random > > def new_name(): > with open('PL_surnames.csv', newline='') as

Re: (yet another) Custom templatetag raising KeyError when DEBUG=False

2014-12-22 Thread Collin Anderson
Hi, Do you have more of your traceback? Are you sure this is your "home" view that's being called? Is this happening in an included template? Collin On Saturday, December 20, 2014 3:27:00 PM UTC-6, Alexandre Provencio wrote: > > Hello all, this is a cross post i made on stackoverflow > >

Problem with google calendar on ancient django version

2014-12-22 Thread Roy Smith
I'm in the process of incrementally upgrading a site running some ancient software (django 1.3.1 and django-cms 2.2). I've got a development version of the site running django-cms 2.3.8 (and still django 1.3.1) for testing. The plan is to get it up to modern versions of both, but one step at

Re: Database queries location

2014-12-22 Thread Collin Anderson
Hi, There's a good example of creating a custom manager here: https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers Collin On Saturday, December 20, 2014 8:28:57 AM UTC-6, pythonista wrote: > > Thank you for your response. > > Most of my data is complex raw sql. > I had

Poll Tutorial (for Django 1.7) Files Available?

2014-12-22 Thread Ken Wayne
I'm trying to work through the Poll Tutorial and I've run into some problems. I'd like to compare the code I've written to a working file. Is there any place to download the entire working project? -- You received this message because you are subscribed to the Google Groups "Django users"

Re: malicious requests?

2014-12-22 Thread Fergus Cameron
On 22/12/2014, Alasdair Nicol wrote: > [ ... ] > > In Django 1.7, the trailing dot is stripped when performing host > > validation, thus an entry with a trailing dot isn’t required. How odd, since the canonical representation would be to add a dot when one is missing

Re: Thinking about EAV database model for flexibility. How (in)compatible is it with the django model?

2014-12-22 Thread Jamie Lawrence
Well, Django, in the role of an ORM, is necessarily pretty coupled to SQL. I know people have been toying with nosql databases with Django; I don't know much about those efforts. EAV intentionally defeats the intended use of RDBMSes by ignoring normalization and data typing, thus (among other

Re: Thinking about EAV database model for flexibility. How (in)compatible is it with the django model?

2014-12-22 Thread Erik Cederstrand
> Den 22/12/2014 kl. 11.27 skrev Felipe Faraggi : > > I'd like to 're-open' this question to ask another (maybe) short one: > > Therefore, is django not very suitable for NOSQL databases like mongo or > couch or others in general? > Or is the problem specifically using

Re: Raw access to cache table

2014-12-22 Thread Erik Cederstrand
Hi Russel, > Den 22/12/2014 kl. 00.40 skrev Russell Keith-Magee : > > If you *do* want to do complex queries on the database cache table, the > approach suggested by Collin is as good an approach as any. A managed table > will give you ORM operations over an arbitrary

Re: Raw access to cache table

2014-12-22 Thread Erik Cederstrand
Hi Colin, > Den 21/12/2014 kl. 05.55 skrev Collin Anderson : > > If you want a nicer interface, I just ran manage.py inspecdb on one of my > databases and got this for the cache table. Not sure why django still does it > by hand. > > class Cache(models.Model): >

Foked Django Mezzanine with Query-less database SearchQuerySet integration [Gazelle]

2014-12-22 Thread Robert Steckroth
Hello community, I wanted to show interest in collaborating on an opensource Django application called Gazelle (a fork of Mezzanine). I built a SearchQuerySet with a drop in replacement to the filter() command which does not hit the database. So, far the results are promising and I am opening the

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-22 Thread Carsten Fuchs
Hi Alex, Am 20.12.2014 um 22:47 schrieb Alex Haylock: Take a look at the Django signal dispatcher: https://docs.djangoproject.com/en/dev/topics/signals/ Specifically, the 'update_fields' argument passed to the 'pre_save' signal should provide what you need:

Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-22 Thread Carsten Fuchs
Hi Collin, Am 20.12.2014 um 00:18 schrieb Collin Anderson: save_model() happens first, then save_related() which calls save_formset() on each formset. It might end up being easier to save the parent model _again_, instead of doing something before it's saved. Thank you very much for your

Re: Model form with optional fields issue

2014-12-22 Thread marcin . j . nowak
> > > > What do you think - is this expected? > > Yes, this is expected. Django's form system is designed for use with > HTML forms, which do not provide partial data: unchanged field values > are sent too, so this problem does not occur. > I thought that Web framework can validate

Difference between Q and filter and exclude

2014-12-22 Thread Larry Martell
Is there any difference, either functional or performance wise, between these 2 constructs: Q(f=1) and filter(f=1) Or, between these 2: (~Q(f=1)) and exclude(f=1) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group

Re: malicious requests?

2014-12-22 Thread Alex Haylock
Thanks Alasdair, that's really useful. I'm using v1.6.X in production, which makes sense based on your email. Alex. On 22/12/14 13:58, Alasdair Nicol wrote: > Hi Alex, > > There is no security implication adding 'example.com.' (with trailing > dot) to your ALLOWED_HOSTS setting. There is some

Re: filter Datetimefield

2014-12-22 Thread Jan Duzinkiewicz
It's hard to answer without seeing what's in your db, and what are the values of ano/mes/dia variables, but: - maybe you do not have pytz package installed (you can install with 'pip install pytz') - though in that case you should get an error when trying to access the results - maybe the day

Re: malicious requests?

2014-12-22 Thread Alasdair Nicol
Hi Alex, There is no security implication adding 'example.com.' (with trailing dot) to your ALLOWED_HOSTS setting. There is some more information in the ALLOWED_HOSTS setting docs. From https://docs.djangoproject.com/en/1.7/ref/settings/#allowed-hosts In previous [<= 1.6.X] versions of

Re: malicious requests?

2014-12-22 Thread Mark Phillips
Alex, The trailing period could be from online promotional materials for your site. Someone may have written your URL with the trailing period inside the URL by mistake when the promotional materials were created. It may not be an attack vector from a malicious hacker, but instead, valid users

Re: malicious requests?

2014-12-22 Thread Alex Haylock
Thanks Markus. So, as per the RFC, are 'example.com' and 'example.com.' considered to be the same domain, or two separate domains? Are there any security implications if I add 'example.com.' to ALLOWED_HOSTS to cater for these requests? Thanks, Alex. On 22/12/14 11:52, Markus Holtermann

Re: malicious requests?

2014-12-22 Thread Markus Holtermann
Hey Alex, a trailing . in the host header is valid per RFC 3986: http://tools.ietf.org/html/rfc3986#section-3.2.2: The rightmost domain label of a fully qualified domain name in DNS may be > followed by a single "." /Markus On Monday, December 22, 2014 12:44:25 PM UTC+1, Alex Haylock

malicious requests?

2014-12-22 Thread Alex Haylock
Are there any known attack vectors that involve appending a period/ full-stop to a sites domain name? My Django application throws a handful of errors in production every day: ERROR: Invalid HTTP_HOST header: 'www.example.com.'. You may need to add u'www.example.com.' to ALLOWED_HOSTS. (note

Re: Can't open manage.py

2014-12-22 Thread Valéria Pacheco
tks! that was it! Sorry for the ignorance, but i'm starting with python too! Sexta-feira, 19 de Dezembro de 2014 12:00:01 UTC, Guilherme Leal escreveu: > > Are you sure that your shell is running on the same folder that contains > the manage.py? > > Em Fri Dec 19 2014 at 09:53:05, Valéria

Re: Thinking about EAV database model for flexibility. How (in)compatible is it with the django model?

2014-12-22 Thread Felipe Faraggi
I'd like to 're-open' this question to ask another (maybe) short one: Therefore, is django not very suitable for NOSQL databases like mongo or couch or others in general? Or is the problem specifically using RDBMS in a NoSQL manner? Because if using NOSQL, the whole model system would be