Re: How do django Field type hints work?

2022-09-23 Thread Justin Black
That article doesn't explain where and how the DecimalField class describes
its type as Decimal to python and pycharm. What line does that?

On Fri, Sep 23, 2022, 8:36 PM Mohammad Anarul 
wrote:

> You can following the article
>
>
> https://www.geeksforgeeks.org/decimalfield-django-models/amp/
>
> On Sat, Sep 24, 2022, 5:09 AM Justin Black 
> wrote:
>
>> Hello there,
>>
>> If I have a model:
>>
>> class Money(models.Model):
>> price = models.DecimalField()
>>
>> m = Money(...)
>> pycharm knows that m.price is of type Decimal but when I read through the
>> django code base, I don't see DecimalField or Field subclassing
>> decimal.Decimal
>> And I don't see any registration code that registers DecimalField as type
>> Decimal
>>
>> How does django do this?
>>
>> --
>> 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/2b1d5103-7aa4-4882-b1a8-f88ec43293d2n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/2b1d5103-7aa4-4882-b1a8-f88ec43293d2n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/IDkt5miBpA0/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAE59x8e_8AJsuM%3D4PYNvJecb-hy2wAXvV7N0%2BkjewqJxPw_LNQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE59x8e_8AJsuM%3D4PYNvJecb-hy2wAXvV7N0%2BkjewqJxPw_LNQ%40mail.gmail.com?utm_medium=email_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/CALoW4woyJDw4U%3DBJ4gz2aHDreGCQpf1tE14V2O1TUor_cu5Nbg%40mail.gmail.com.


How do django Field type hints work?

2022-09-23 Thread Justin Black
Hello there,

If I have a model:

class Money(models.Model):
price = models.DecimalField()

m = Money(...)
pycharm knows that m.price is of type Decimal but when I read through the 
django code base, I don't see DecimalField or Field subclassing 
decimal.Decimal
And I don't see any registration code that registers DecimalField as type 
Decimal

How does django do this?

-- 
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/2b1d5103-7aa4-4882-b1a8-f88ec43293d2n%40googlegroups.com.


Django Model related_name

2022-09-06 Thread Justin Kpakpa
Hello, pls under what circumstances do you need to defined a related_name of a 
model field?

-- 
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/63171f1d.170a0220.87ca8.aef5%40mx.google.com.


RE: Including URLconf

2022-03-07 Thread Justin Kpakpa
Sent from my GalaxyVisit your settings.py file and include the app in 
INSTALLED_APPS. Check if that works.
 Original message From: Alec Greenholdt  
Date: 07/03/2022  00:24  (GMT+00:00) To: Django users 
 Subject: Including URLconf as described in the 
documentation i am putting this code in. as soon as i put in "path('polls/', 
include('polls.urls'))," i get the following error. Please help



-- 
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/51cb96bf-09ef-4e7c-8000-670b5f5b5b9an%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/6226a5ac.1c69fb81.a3610.d2cb%40mx.google.com.


Re: SQLite 3.8.3 or later is required (found 3.7.17).

2019-11-05 Thread amul justin
Tq so much bro can u send u r contact number pls im from tamilnadu

On Saturday, July 20, 2019 at 6:32:21 PM UTC+5:30, Desh Deepak wrote:
>
> Sorry for the late reply, 
>
> You can try these commands on your terminal:-
>
> pip uninstall Django
>
> Then
>
> pip install Django 2.0
>
> and try to run the server again.
>
>
> Thanks and regards:-
>  Desh Deepak
>  deshde...@gmail.com 
>  +917011101001
>
> On Fri, 19 Jul 2019, 18:06 anchal agarwal,  > wrote:
>
>> Hello Django users,
>> i am trying to deploy my django on AWS 
>> I am following this 
>> https://medium.com/@charlesthk/deploy-nginx-django-uwsgi-on-aws-ec2-amazon-linux-517a683163c6
>> Everything was going right but when i run python manage.py migrate , it's 
>> giving me this error
>> django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is 
>> required (found 3.7.17).
>> how can i resolve this?
>> Please help me 
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAMT%3DisVCsYAju5agUWxPrpjZ5a-NGc1X0A7U34c4QthnAM0jKA%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/172bcb3a-6182-40dc-96b6-327ad365a326%40googlegroups.com.


Re: Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Thanks for the tips.

I didn't think about referencing a CDN, but I suppose that's a better
default, and if people want local copies then they can make their own.

Json2 probably shouldn't be in there. I've been dragging that file around
for years without really thinking about it. If anyone really needs to
support old IE they should know to include it themselves.

Justin

On Wed, Jun 13, 2018 at 7:45 PM, Jason  wrote:

> ooh, nice!  missed that part.
>
> Did you consider having that pull from a CDN rather than locally?  Reason
> being, any updates to said polyfills will require you to deploy an update.
> Whereas if you have a template tag to pull from a CDN, you can have your
> users specify the version if necessary and pull the latest by default.
> Would be one less thing you have to worry about maintaining.
>
> https://cdnjs.com/libraries/event-source-polyfill
> https://www.jsdelivr.com/package/npm/reconnecting-eventsource
>
> Also, what's the reason for having json2 in the static files?
> https://github.com/douglascrockford/JSON-js even states
>
> On current browsers, this file does nothing, preferring the built-in JSON 
> object. There is no reason to use this file unless fate compels you to 
> support IE8, which is something that no one should ever have to do again.
>>
>>
> Other than that, the lib looks pretty good to me.  
>
> On Wednesday, June 13, 2018 at 9:20:44 PM UTC-4, Justin Karneges wrote:
>>
>> Thanks Jason! The library comes with Yaffle's polyfill for IE/Edge
>> support, that can be included with a template tag.
>>
>> https://github.com/fanout/django-eventstream#receiving-in-the-browser
>>
>> On Wed, Jun 13, 2018 at 5:20 PM, Jason  wrote:
>>
>>> Nice library!  good work :-)
>>>
>>> I would suggest you update your readme to reflect that SSE is not
>>> supported by any MS browser (IE or Edge) as shown by
>>> https://caniuse.com/#feat=eventsource.
>>>
>>>
>>> On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:
>>>>
>>>> Hi folks,
>>>>
>>>> I'm pleased to announce an SSE library for Django:
>>>> https://github.com/fanout/django-eventstream
>>>>
>>>> The library makes pushing data from the server really easy. It uses
>>>> Channels under the hood, although you don't have to write any async code.
>>>> Simply declare endpoints in routing.py and call send_event() from anywhere.
>>>>
>>>> I hope others find it useful.
>>>>
>>>> Justin
>>>>
>>>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOTs0uCjsCAd_PzKFcF8WLHitWYmHHnd6TeigU8Mf9pcPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Thanks Jason! The library comes with Yaffle's polyfill for IE/Edge support,
that can be included with a template tag.

https://github.com/fanout/django-eventstream#receiving-in-the-browser

On Wed, Jun 13, 2018 at 5:20 PM, Jason  wrote:

> Nice library!  good work :-)
>
> I would suggest you update your readme to reflect that SSE is not
> supported by any MS browser (IE or Edge) as shown by
> https://caniuse.com/#feat=eventsource.
>
>
> On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:
>>
>> Hi folks,
>>
>> I'm pleased to announce an SSE library for Django:
>> https://github.com/fanout/django-eventstream
>>
>> The library makes pushing data from the server really easy. It uses
>> Channels under the hood, although you don't have to write any async code.
>> Simply declare endpoints in routing.py and call send_event() from anywhere.
>>
>> I hope others find it useful.
>>
>> Justin
>>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOQbaWJ_NbNYRzWAryN3pwZqmmr8Z16R24eqRjsWUsasHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Hi folks,

I'm pleased to announce an SSE library for Django:
https://github.com/fanout/django-eventstream

The library makes pushing data from the server really easy. It uses
Channels under the hood, although you don't have to write any async code.
Simply declare endpoints in routing.py and call send_event() from anywhere.

I hope others find it useful.

Justin

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOQ4-s6xOSWfthEiddpKRYgMYs4y15V_XRn1SOBvz_SZqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Redirect Loops and 404 with Django Channels and runserver command

2018-06-08 Thread Justin Lee


I was just trying to integrate channels into an existing django/DRF project 
and I have been running into an issue where my original urls paths are 
breaking when I do runserver. My root index view leads to 301 infinite 
redirects loop and my other app views results in a 404. The Socket server 
is definitely up as I have tried to do the following in console. It is just 
the http views + routes that are somehow breaking



var chatSocket = new WebSocket('ws://' + window.location.host + '/');

chatSocket.onmessage = function(e) {

var data = JSON.parse(e.data);

var message = data['message'];

console.log(message)

}

chatSocket.send(JSON.stringify({'message': "Hello World"}));


OUTPUT:

VM862:4 Hello World



The app works when I remove "channels" from installed_apps

It also works if I try to run the asgi app through daphne directly

I just want the app to work in django dev runserver


I am using django auth backend with login_required for all my views.

I am fairly new to django and would love some help on this! 

my_app/urls.py

urlpatterns = [
path('users/', include('django.contrib.auth.urls')),
path('admin/', admin.site.urls),
path('api/', include('api.urls', namespace='api')),
url(r'^.*', index, name='index'),
]

my_app/routing.py

from channels.auth import AuthMiddlewareStackfrom channels.routing import 
ProtocolTypeRouter, URLRouterfrom django.urls import path
from api.consumer import EchoConsumer

application = ProtocolTypeRouter({
'websocket': AuthMiddlewareStack(
URLRouter([
path('', EchoConsumer)
])
)
})

Settings

# Application definitionINSTALLED_APPS = [
'channels',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'django_extensions',
'rest_framework',
'rfs.apps.RfsConfig',
'api.apps.ApiConfig',
'import_export',
]
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',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

Versions

channels==2.1.1
daphne==2.1.2

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de5f781b-ecca-4c7c-a1f5-3b01fff26531%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Borrowing functionality from Django Admin forms

2018-03-07 Thread Justin Johnson
I have a user who saw how new objects can be created using the Admin forms, 
and asked if I could reproduce some of that functionality.  I'm still new 
to Django, and even newer to building forms.  I'm wondering if there is a 
way to "borrow" elements from the Admin forms into my own forms and 
templates.  Particularly, I would like the ability to create a new related 
object by clicking the "+" sign next to that dropdown list on another form.

I have not been able to find much documentation on how the Admin forms are 
constructed for a given Django project.  I understand the basic form 
construction method, but I can't seem to find the equivalent workings in 
the Admin site.  Where is the equivalent of urls.py, where the links are 
mapped to specific Views?  Where are the equivalents of the Views, where a 
context is created and sent to the template?

I would like to get more familiar with the working code behind Django, and 
eventually contribute to the project, so feel free to get technical.

Thx.


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92f87737-2be9-4a04-8840-2edc14452b43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


GeoDjango GDAL Slice Error in layer.py

2018-01-12 Thread Justin Johnson



I'm completely new to GeoDjango.  I'm working through the tutorial for 
Django version 2.0, and I am encountering an error when I follow the steps 
in the GeoDjango section.  

Specifically, when I attempt to slice a Layer object to extract Features, 
it gives me an error which looks like a possible bug.   I'll go through the 
steps here.


   1. 
   
https://docs.djangoproject.com/en/2.0/ref/contrib/gis/tutorial/#importing-spatial-data
   1. in this section of the tutorial, we import spatial data and use the 
  GDAL library to work with an imported shapefile of world borders
  2. Next, through the Django shell, I create a DataSource object 
  

 
  using the *django.contrib.gis.gdal *module
  3. I am able to retrieve, from this DataSource object, a Layer object 
   
  containing Features for each polygon
  4. I can work through the examples showing the properties of that 
  Layer object, and iterate through the Features in the Layer, so I know 
  that's working
   2. The problem is when I try to Slice a Layer, to extract a subset of 
   Features: 
  1. The example says I should be able to run  *>>> lyr[0:2]* and 
  receive two Feature objects
  2. However, what I get is an error message saying there is an 
  IndexError, and it mentions a TypeError
   

This is an image of the Traceback





And here is the traceback in text:



In [12]: lyr[0:2]
---
IndexErrorTraceback (most recent call last)
 in ()
> 1 lyr[0:2]

c:\projects\python\env\ENV3\lib\site-packages\django\contrib\gis\gdal\layer.py 
in __getitem__(self, index)
 49 # A slice was given
 50 start, stop, stride = index.indices(self.num_feat)
---> 51 return [self._make_feature(fid) for fid in range(start, 
stop, stride)]
 52 else:
 53 raise TypeError('Integers and slices may only be used 
when indexing OGR Layers.')

c:\projects\python\env\ENV3\lib\site-packages\django\contrib\gis\gdal\layer.py 
in (.0)
 49 # A slice was given
 50 start, stop, stride = index.indices(self.num_feat)
---> 51 return [self._make_feature(fid) for fid in range(start, 
stop, stride)]
 52 else:
 53 raise TypeError('Integers and slices may only be used 
when indexing OGR Layers.')

c:\projects\python\env\ENV3\lib\site-packages\django\contrib\gis\gdal\layer.py 
in _make_feature(self, feat_id)
 88 return feat
 89 # Should have returned a Feature, raise an IndexError.
---> 90 raise IndexError('Invalid feature id: %s.' % feat_id)
 91
 92 #  Layer properties 

IndexError: Invalid feature id: 0.



Again, I'm totally new to GeoDjango, so this could all be a user error.  I 
have restarted the tutorial 3 times and it always fails at the slice 
example.  The comment in the Traceback mentioning an IndexError has me 
wondering.

Thanks in advance.


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a8fb48a0-8bcd-41bb-a3ce-737c324d96cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django tutorial - Misleading instructions

2017-06-29 Thread Justin Stubbs
Hi Guys,

Im following the 
tutorial https://docs.djangoproject.com/en/1.11/intro/tutorial03/ and have 
found that the section on templates doesn't appear to be correct.

The section talks about how django templates are loaded by default if you 
put them in the correct path:


<https://lh3.googleusercontent.com/-lJdY4kudaBg/WVWk2j9nr0I/BNw/ymN-99SZwfAqblDJ0VeIjXD9dWIpoui-gCLcBGAs/s1600/dir_structure.png>



def auth(request):
return render(request, 'g_auth/index.html')




but when I used a similar example django complained about not being able to 
find the templates. I ended up having to change the django settings file 
'DIRS':

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'g_auth/templates')
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]


After 
reading https://docs.djangoproject.com/en/1.11/ref/templates/upgrading/

Hoping to get this clarified as for a beginner this would be quite 
complicated(assuming I haven't missed the boat completely here)

Cheers,

Justin

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d42b6488-73a9-4cc3-aeaf-2d9d00e5b124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form Inheritance. Order is Reversed.

2017-01-11 Thread Justin J
For anyone interested,

In django/django/forms/forms.py  ln 45:

# Walk through the MRO.
declared_fields = OrderedDict()
for base in reversed(new_class.__mro__):
# Collect fields from base class.
if hasattr(base, 'declared_fields'):
declared_fields.update(base.declared_fields)



"reverse(new_class.__mro__)" is causing order of inherited forms to be 
reversed. 

DeclarativeFieldsMetaclass was reworked for version 1.7 and I don't know what 
the intended behavior is so I am not opening a ticket.


I tested with two unrelated Django applications and I found the same results in 
both.


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eac8a367-dd9d-4694-a019-903de1f8166e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form Inheritance. Order is Reversed.

2017-01-10 Thread Justin J
Thanks Mathew,

I do have multiple forms, and that is why the nested loop.

I'm going to try to upgrade to the latest 1.10 and see if it solves the 
problem. If anything I will be able to use the field_order attribute.

I reverted to a commit before I upgraded from 1.5 to 1.8 and the problem 
was not present, so I suspect the upgrade changed some related behavior. 
Maybe it was that change in ver. 1.7 as you suggested.




On Monday, January 9, 2017 at 9:19:34 AM UTC-8, Justin J wrote:
>
> I have a form which is sublassing 3 forms, and has no new fields.
>
> class D(A, B, C):
> pass
>
>
> form class B is subclassing 2 forms.
>
> class B(B1, B2):
> pass
>
>
>
> In the template I am looping through the form.
>
> {% for d in forms.myforms %}
> {% for field in d.form.visible_fields %}
> 
> {% endfor %}
> {% endfor %}
>
>
>
> This was working as expected until recently. Form classes A, B, C are 
> displayed in reverse order now, and B1, B2 are also reversed. However, 
> fields within B2 are still in the order declared.
>
> The only thing I can think of that changed recently was an upgrade from 
> Django 1.5 to 1.8. I have no clue if it is related.
>
> Anyone experience this before?
>
> Thanks for any suggestions. 
>
>
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be3f676d-317c-498b-834e-a048aa5ee341%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form Inheritance. Order is Reversed.

2017-01-09 Thread Justin J
I have a form which is sublassing 3 forms, and has no new fields.

class D(A, B, C):
pass


form class B is subclassing 2 forms.

class B(B1, B2):
pass



In the template I am looping through the form.

{% for d in forms.myforms %}
{% for field in d.form.visible_fields %}

{% endfor %}
{% endfor %}



This was working as expected until recently. Form classes A, B, C are 
displayed in reverse order now, and B1, B2 are also reversed. However, 
fields within B2 are still in the order declared.

The only thing I can think of that changed recently was an upgrade from 
Django 1.5 to 1.8. I have no clue if it is related.

Anyone experience this before?

Thanks for any suggestions. 



-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8caa622b-5cf2-4869-aa0f-a7aa68a3b50f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access request body in the django.request logger

2016-11-07 Thread Justin Wilson
Sorry, I had those reversed. It works find WITH uWSGI, and fails with the 
Django dev server.

On Monday, November 7, 2016 at 2:48:14 PM UTC-7, Justin Wilson wrote:
>
> Stumbled across this post while trying to solve the same issue 
> *(we've had this issue since 1.10 release, but have kept with 1.9 due to 
> this issue).*We're only getting this with Django 1.10+ when running 
> behind uWSGI.
> The issue goes away if we just run the Django dev server.
>
> On Thursday, September 15, 2016 at 11:09:13 PM UTC-6, Ben Whale wrote:
>>
>> Thanks for a link to the blob, that is very helpful.
>>
>> You might be right, but the more I look at this the more I think it is a 
>> bug.
>>
>> The logging message is generated in django/utils/log.py in 
>> the ServerFormatter format() method. If the logging setting is 
>>
>> LOGGING = {   
>>   
>> 'version': 1, 
>>
>> 'disable_existing_loggers': False,   
>> 
>> 'formatters': {   
>>  
>> 'verbose': { 
>>   
>> 'format': '%(levelname)s %(asctime)s %(module)s 
>> %(process)d %(thread)d %(message)s'
>> },   
>>   
>> 'simple': {   
>>  
>> 'format': '%(levelname)s %(message)s' 
>>  
>> },   
>>   
>> 'django.server': {   
>>   
>> '()': 'django.utils.log.ServerFormatter', 
>>  
>> 'format': '[%(server_time)s] %(message)s %(request)r',   
>>   
>> } 
>>  
>> },   
>>   
>> 'filters': { 
>>   
>> 'require_debug_false': { 
>>   
>> '()': 'django.utils.log.RequireDebugFalse',   
>>  
>> },   
>>   
>> 'require_debug_true': {   
>>  
>> '()': 'django.utils.log.RequireDebugTrue',   
>>   
>> },   
>>   
>> },   
>>   
>> 'handlers': { 
>>  
>> 'console': { 
>>   
>> 'level': 'DEBUG', 
>>  
>> 'filters': ['require_debug_true'], 

Re: Access request body in the django.request logger

2016-11-07 Thread Justin Wilson
Stumbled across this post while trying to solve the same issue 
*(we've had this issue since 1.10 release, but have kept with 1.9 due to 
this issue).*We're only getting this with Django 1.10+ when running behind 
uWSGI.
The issue goes away if we just run the Django dev server.

On Thursday, September 15, 2016 at 11:09:13 PM UTC-6, Ben Whale wrote:
>
> Thanks for a link to the blob, that is very helpful.
>
> You might be right, but the more I look at this the more I think it is a 
> bug.
>
> The logging message is generated in django/utils/log.py in 
> the ServerFormatter format() method. If the logging setting is 
>
> LOGGING = {   
>   
> 'version': 1, 
>
> 'disable_existing_loggers': False, 
>   
> 'formatters': {   
>  
> 'verbose': {   
> 
> 'format': '%(levelname)s %(asctime)s %(module)s 
> %(process)d %(thread)d %(message)s'
> }, 
> 
> 'simple': {   
>  
> 'format': '%(levelname)s %(message)s' 
>  
> }, 
> 
> 'django.server': { 
> 
> '()': 'django.utils.log.ServerFormatter', 
>  
> 'format': '[%(server_time)s] %(message)s %(request)r', 
> 
> } 
>  
> }, 
> 
> 'filters': {   
> 
> 'require_debug_false': {   
> 
> '()': 'django.utils.log.RequireDebugFalse',   
>  
> }, 
> 
> 'require_debug_true': {   
>  
> '()': 'django.utils.log.RequireDebugTrue', 
> 
> }, 
> 
> }, 
> 
> 'handlers': { 
>  
> 'console': {   
> 
> 'level': 'DEBUG', 
>  
> 'filters': ['require_debug_true'], 
> 
> 'class': 'logging.StreamHandler', 
>  
> }, 
> 
> 'django.server': { 
> 
> 'level': 'INFO',   
> 
> 

Re: runserver request body limitations

2015-07-01 Thread Justin Karneges
Hmm, possibly it could be that chunked encoded request bodies are not
supported:
http://osdir.com/ml/modwsgi/2010-09/msg00091.html

(As for how I managed to send 35K earlier, maybe it was some kind of
packetization luck. I'm unable to reproduce it now. The Django app keeps
seeing 0 bytes for a chunked upload).

On Wed, Jul 1, 2015 at 4:17 PM, Justin Karneges <jus...@fanout.io> wrote:

> It appears that once a certain size is exceeded, the request body is not
> received at all or truncated to 0.
>
> Here's a minimal view that echos the request body:
>
> def echo(request):
> return HttpResponse(request.body)
>
> Then I'm sending files like this:
>
> curl -v -X PUT --data-binary @file -H "Transfer-Encoding: chunked"
> http://localhost:8000/echo/
>
> The runserver output will display 0 bytes sent if I try to send a too big
> file:
>
> [01/Jul/2015 23:15:05]"PUT /echo/ HTTP/1.1" 200 0
>
> On Wed, Jul 1, 2015 at 2:10 PM, Avraham Serour <tovm...@gmail.com> wrote:
>
> What do you mean by trouble, be more specific
>>
>> On Wed, Jul 1, 2015, 11:06 PM Justin Karneges <jus...@fanout.io> wrote:
>>
>>> Hi folks,
>>>
>>> I'm running into trouble doing a PUT with chunked encoded request body
>>> when the size exceeds around 35K. This is with runserver, so there's no
>>> Apache or wsgi or anything here.
>>>
>>> Are there any request body size limits in Django or specifically in
>>> runserver? Trying to isolate whether this issue is on the sender side or
>>> Django side.
>>>
>>> Thanks,
>>> Justin
>>>
>>>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOTxERBp-Fxj%3DzVJKDyPoXDHNEXMs7hR9ef5cOEh8pxJ0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: runserver request body limitations

2015-07-01 Thread Justin Karneges
It appears that once a certain size is exceeded, the request body is not
received at all or truncated to 0.

Here's a minimal view that echos the request body:

def echo(request):
return HttpResponse(request.body)

Then I'm sending files like this:

curl -v -X PUT --data-binary @file -H "Transfer-Encoding: chunked"
http://localhost:8000/echo/

The runserver output will display 0 bytes sent if I try to send a too big
file:

[01/Jul/2015 23:15:05]"PUT /echo/ HTTP/1.1" 200 0

On Wed, Jul 1, 2015 at 2:10 PM, Avraham Serour <tovm...@gmail.com> wrote:

What do you mean by trouble, be more specific
>
> On Wed, Jul 1, 2015, 11:06 PM Justin Karneges <jus...@fanout.io> wrote:
>
>> Hi folks,
>>
>> I'm running into trouble doing a PUT with chunked encoded request body
>> when the size exceeds around 35K. This is with runserver, so there's no
>> Apache or wsgi or anything here.
>>
>> Are there any request body size limits in Django or specifically in
>> runserver? Trying to isolate whether this issue is on the sender side or
>> Django side.
>>
>> Thanks,
>> Justin
>>
>>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOQfvE3aWZ_KCDHh8HVZ4tnzp3zjXeMjaRTzjLWNRu4bHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


runserver request body limitations

2015-07-01 Thread Justin Karneges
Hi folks,

I'm running into trouble doing a PUT with chunked encoded request body when
the size exceeds around 35K. This is with runserver, so there's no Apache
or wsgi or anything here.

Are there any request body size limits in Django or specifically in
runserver? Trying to isolate whether this issue is on the sender side or
Django side.

Thanks,
Justin

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOS9GpimmhOkFKyyS9%3DOG65ofUibdqhwBso%2BR3q94Uvn8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: A migration in one app that adds a field to another

2014-11-04 Thread Justin Myles Holmes
Carl:

Actually, the "subclass the operation" method fails for obvious reasons
here:

https://github.com/django/django/blob/df0523debcc2d0984f1bc11d323f04227d4b388b/django/apps/registry.py#L202

I'm increasingly thinking that using MIGRATION_MODULES and just
maintaining a local copy of Mezzanine's migration is the simplest
solution.  I sense that I'm going to face some resistance if I suggest
changing their docs to reflect this.  I'll start with a blog post.


On 11/04/2014 04:30 PM, Justin Myles Holmes wrote:
> Well, as I say, I don't particularly like this field injection notion,
> and I'm happy to individually subclass where needed in my own projects.
>
> I'm less surefooted about issuing a pull request to mezzanine to alter
> their docs to suggest doing this, although the doc is currently
> ambiguous enough to be of little use anyway.
>
> I think that you and Carl have changed my mind about the
> reasonableness of including migrations in one app for a model in
> another.  I'm no longer able to think of a scenario that justifies it.
>
>
> On 11/04/2014 04:12 PM, Andrew Godwin wrote:
>> Carl is right that this isn't a supported thing; Django models are
>> designed to be static, and not mutate based on settings.
>>
>> Migrations are designed to only support one linear change history of
>> models; swappable models are just about supported but not perfect and
>> leads to issues. Adding in the ability to change or remove other
>> fields based on installed models is kind of against the way
>> migrations is designed and you'll have to do a lot of work to get
>> around it.
>>
>> In this particular case, it's possible to make it work, but you'll
>> have to subclass every one of the actions you want to use and provide
>> a way to override the app_label it operates on, and manually
>> construct the migrations to get the dependencies correct and
>> non-circular (as I said, you'll have to do a lot of work to get
>> around it). As long as you have anything resembling magically
>> changing models in your project, you're not going to be able to use
>> anything makemigrations outputs and expect it to Just Work™.
>>
>> Andrew
>>
>> On Tuesday, November 4, 2014 3:59:23 PM UTC-8, Carl Meyer wrote:
>>
>> Hi Justin,
>>
>> On 11/04/2014 04:42 PM, Justin Myles Holmes wrote:
>> >> I don't understand this use case. A ForeignKey impacts only
>> one database
>> > table's schema; the table for the model on which the ForeignKey
>> field is
>> > located. The schema of the model the ForeignKey points to
>> doesn't need
>> > to change at all based on the presence or absence of some other
>> > ForeignKey pointing to it.
>> >
>> > Example:
>> >
>> > Two apps: apps.coconuts and apps.swallows, each with a
>> canonical model
>> > (Coconut and Swallow, respectively).
>> >
>> > The organization runs two version of the project: one with
>> apps.swallows
>> > and one without.
>> >
>> > The one with apps.swallows needs a field on Coconut, "carried,"
>> which is
>> > a FK -=> Swallow.
>>
>> This is basically the same use case as the Mezzanine one - it's
>> attempting to make a model more "reusable" by monkeypatching it with
>> additional fields from outside. I think this should be avoided and
>> discouraged, not better supported.
>>
>> The specifics of how to avoid would depend on details of the
>> case, but I
>> would look towards providing the reusable portions of the model
>> as an
>> abstract base, and maybe additionally using swappable models if
>> other
>> models need to have an FK to the "extendable" model.
>>
>> (Swappable models aren't yet formally supported for use outside
>> contrib.auth, and there are still rough edges in migration's
>> support for
>> them, but I think moving them towards formal support is a much
>> better
>> answer to this general use case than monkeypatching fields onto
>> models.)
>>
>> Another possibility (which I still don't like, but is better than
>> monkeypatching) might be to conditionally define the Coconut.carried
>> field, depending on the value of a setting. In that case, the right
>> solution for migrations is to still define the migration that
>> adds the
>> Coconut.carried field in the coconuts app, but make it
>> conditiona

Re: A migration in one app that adds a field to another

2014-11-04 Thread Justin Myles Holmes
Well, as I say, I don't particularly like this field injection notion,
and I'm happy to individually subclass where needed in my own projects.

I'm less surefooted about issuing a pull request to mezzanine to alter
their docs to suggest doing this, although the doc is currently
ambiguous enough to be of little use anyway.

I think that you and Carl have changed my mind about the reasonableness
of including migrations in one app for a model in another.  I'm no
longer able to think of a scenario that justifies it.


On 11/04/2014 04:12 PM, Andrew Godwin wrote:
> Carl is right that this isn't a supported thing; Django models are
> designed to be static, and not mutate based on settings.
>
> Migrations are designed to only support one linear change history of
> models; swappable models are just about supported but not perfect and
> leads to issues. Adding in the ability to change or remove other
> fields based on installed models is kind of against the way migrations
> is designed and you'll have to do a lot of work to get around it.
>
> In this particular case, it's possible to make it work, but you'll
> have to subclass every one of the actions you want to use and provide
> a way to override the app_label it operates on, and manually construct
> the migrations to get the dependencies correct and non-circular (as I
> said, you'll have to do a lot of work to get around it). As long as
> you have anything resembling magically changing models in your
> project, you're not going to be able to use anything makemigrations
> outputs and expect it to Just Work™.
>
> Andrew
>
> On Tuesday, November 4, 2014 3:59:23 PM UTC-8, Carl Meyer wrote:
>
> Hi Justin,
>
> On 11/04/2014 04:42 PM, Justin Myles Holmes wrote:
> >> I don't understand this use case. A ForeignKey impacts only one
> database
> > table's schema; the table for the model on which the ForeignKey
> field is
> > located. The schema of the model the ForeignKey points to
> doesn't need
> > to change at all based on the presence or absence of some other
> > ForeignKey pointing to it.
> >
> > Example:
> >
> > Two apps: apps.coconuts and apps.swallows, each with a canonical
> model
> > (Coconut and Swallow, respectively).
> >
> > The organization runs two version of the project: one with
> apps.swallows
> > and one without.
> >
> > The one with apps.swallows needs a field on Coconut, "carried,"
> which is
> > a FK -=> Swallow.
>
> This is basically the same use case as the Mezzanine one - it's
> attempting to make a model more "reusable" by monkeypatching it with
> additional fields from outside. I think this should be avoided and
> discouraged, not better supported.
>
> The specifics of how to avoid would depend on details of the case,
> but I
> would look towards providing the reusable portions of the model as an
> abstract base, and maybe additionally using swappable models if other
> models need to have an FK to the "extendable" model.
>
> (Swappable models aren't yet formally supported for use outside
> contrib.auth, and there are still rough edges in migration's
> support for
> them, but I think moving them towards formal support is a much better
> answer to this general use case than monkeypatching fields onto
> models.)
>
> Another possibility (which I still don't like, but is better than
> monkeypatching) might be to conditionally define the Coconut.carried
> field, depending on the value of a setting. In that case, the right
> solution for migrations is to still define the migration that adds
> the
> Coconut.carried field in the coconuts app, but make it
> conditionally a
> no-op migration based on the value of the same setting.
>
> > To me, the proper way to do this is to ship a migration in the
> swallows
> > app which adds this field to apps.coconuts.models.Coconut.
>
> Sorry, I don't agree that there's anything "proper" about that :-)
> The
> migration is a secondary issue here - the basic problem is that
> you're
> monkeypatching the Coconut model, and I don't think migrations should
> support/encourage one app monkeypatching another app's models.
>
> > This is certainly a rare use case, but not a special case.  On
> the other
> > hand, I don't see the advantage of restricting the models which
> may be
> > migrated to those in the app in which the migration appears,
> > particularly now that migration dependencies are more
&g

Re: A migration in one app that adds a field to another

2014-11-04 Thread Justin Myles Holmes
> I don't understand this use case. A ForeignKey impacts only one database
table's schema; the table for the model on which the ForeignKey field is
located. The schema of the model the ForeignKey points to doesn't need
to change at all based on the presence or absence of some other
ForeignKey pointing to it.

Example:

Two apps: apps.coconuts and apps.swallows, each with a canonical model
(Coconut and Swallow, respectively).

The organization runs two version of the project: one with apps.swallows
and one without.

The one with apps.swallows needs a field on Coconut, "carried," which is
a FK -=> Swallow.

To me, the proper way to do this is to ship a migration in the swallows
app which adds this field to apps.coconuts.models.Coconut.

This is certainly a rare use case, but not a special case.  On the other
hand, I don't see the advantage of restricting the models which may be
migrated to those in the app in which the migration appears,
particularly now that migration dependencies are more straightforward.

> I also wonder if there might be a way to do (2) without the
monkeypatching. That is, could Mezzanine provide an importable Operation
subclass for this purpose and document how to import and use it in a
migration?

Well, the problem there is that Operation isn't used directly, but
subclassed for each individual type of migration operation. 


On 11/04/2014 03:33 PM, Carl Meyer wrote:



> Hi Justin,
>
> On 11/04/2014 04:17 PM, Justin Myles Holmes wrote:
>> Hey Carl.  Missed you so very much at DjangoCon.  :-)
> Thanks :-)
>
>>> I'm not sure why the mezzanine docs don't mention using the
>> SOUTH_MIGRATION_MODULES setting (or Django 1.7 equivalent
>> MIGRATION_MODULES) to override the location of the mezzanine app's
>> migrations to a package in your project, where you can freely add custom
>> migrations without modifying mezzanine code.
>>
>> While I don't want to speak for Mezzanine (and, frankly, am not crazy
>> about their approach to field injection in the first place), I surmise
>> that they want to be able to both ship their own migrations (when their
>> models change) and allow their users to add their own migrations (for
>> injecting fields).
>>
>> As I say, I don't love the solution, but I do see its advantages over
>> merely providing a mixin, as they have a relationship structure of their
>> own between their models that they want to maintain.
>>
>> You say that it's a reasonable tradeoff; I don't think I agree.  For
>> Django's part, I'm not convinced that, without exception, migrations for
>> a particular model belong in the same app as that model.  I think there
>> are reasonable times to place them elsewhere, and this is one of them. 
>> Another is an occasion in which an organization has its own internal
>> apps and runs versions of its project without and without a particular
>> app.  If that app requires an incoming ForeignKey from a model in a
>> different app, that migration is ideally only implied in the presence of
>> the target app.
> I don't understand this use case. A ForeignKey impacts only one database
> table's schema; the table for the model on which the ForeignKey field is
> located. The schema of the model the ForeignKey points to doesn't need
> to change at all based on the presence or absence of some other
> ForeignKey pointing to it.
>
> It still seems to me that there isn't a good reason for Django to
> support migrations that modify the schema of a model in some other app.
> That's the migrations equivalent of monkeypatching, and I think it will
> usually end in tears :-)
>
>>> I don't see any monkeypatch there, just subclassing, which is not the same 
>>> thing. I'd say that
>> looks like a very nice solution to the problem. The level of "fiddling
>> with internals" required seems roughly proportional to the peculiarity
>> of the use case; I doubt you'll find anything better (other than perhaps
>> avoiding the problem entirely by using MIGRATION_MODULES).
>>
>> I was unclear: What I meant was that a potential solution within the
>> Mezzanine codebase is a monkeypatch which changes the state_forwards
>> method at runtime to comport with the subclass example that I've provided.
> Ah, I see. I didn't realize that you were looking for a generic solution
> in Mezzanine, rather than a solution for your specific Mezzanine-using
> project.
>
>> My question (which at this point probably belongs more on dev than here)
>> is: Which is the most Djangoic approach:
>>
>> 1) Modify the Mezzanine docs to encourage users to take their own
>> action, such as A) using MIGRATION_MODULES or B) manually editing
>> migrations and subclassing

Re: A migration in one app that adds a field to another

2014-11-04 Thread Justin Myles Holmes
> I don't understand this use case. A ForeignKey impacts only one database
table's schema; the table for the model on which the ForeignKey field is
located. The schema of the model the ForeignKey points to doesn't need
to change at all based on the presence or absence of some other
ForeignKey pointing to it.

Example:

Two apps: apps.coconuts and apps.swallows, each with a canonical model
(Coconut and Swallow, respectively).

The organization runs two version of the project: one with apps.swallows
and one without.

The one with apps.swallows needs a field on Coconut, "carried," which is
a FK -=> Swallow.

To me, the proper way to do this is to ship a migration in the swallows
app which adds this field to apps.coconuts.models.Coconut.

This is certainly a rare use case, but not a special case.  On the other
hand, I don't see the advantage of restricting the models which may be
migrated to those in the app in which the migration appears,
particularly now that migration dependencies are more straightforward.

>

I also wonder if there might be a way to do (2) without
the monkeypatching. That is, could Mezzanine provide an importable
Operation subclass for this purpose and document how to import and use
it in a migration?


On 11/04/2014 03:33 PM, Carl Meyer wrote:
> Hi Justin,
>
> On 11/04/2014 04:17 PM, Justin Myles Holmes wrote:
>> Hey Carl.  Missed you so very much at DjangoCon.  :-)
> Thanks :-)
>
>>> I'm not sure why the mezzanine docs don't mention using the
>> SOUTH_MIGRATION_MODULES setting (or Django 1.7 equivalent
>> MIGRATION_MODULES) to override the location of the mezzanine app's
>> migrations to a package in your project, where you can freely add custom
>> migrations without modifying mezzanine code.
>>
>> While I don't want to speak for Mezzanine (and, frankly, am not crazy
>> about their approach to field injection in the first place), I surmise
>> that they want to be able to both ship their own migrations (when their
>> models change) and allow their users to add their own migrations (for
>> injecting fields).
>>
>> As I say, I don't love the solution, but I do see its advantages over
>> merely providing a mixin, as they have a relationship structure of their
>> own between their models that they want to maintain.
>>
>> You say that it's a reasonable tradeoff; I don't think I agree.  For
>> Django's part, I'm not convinced that, without exception, migrations for
>> a particular model belong in the same app as that model.  I think there
>> are reasonable times to place them elsewhere, and this is one of them. 
>> Another is an occasion in which an organization has its own internal
>> apps and runs versions of its project without and without a particular
>> app.  If that app requires an incoming ForeignKey from a model in a
>> different app, that migration is ideally only implied in the presence of
>> the target app.
> I don't understand this use case. A ForeignKey impacts only one database
> table's schema; the table for the model on which the ForeignKey field is
> located. The schema of the model the ForeignKey points to doesn't need
> to change at all based on the presence or absence of some other
> ForeignKey pointing to it.
>
> It still seems to me that there isn't a good reason for Django to
> support migrations that modify the schema of a model in some other app.
> That's the migrations equivalent of monkeypatching, and I think it will
> usually end in tears :-)
>
>>> I don't see any monkeypatch there, just subclassing, which is not the same 
>>> thing. I'd say that
>> looks like a very nice solution to the problem. The level of "fiddling
>> with internals" required seems roughly proportional to the peculiarity
>> of the use case; I doubt you'll find anything better (other than perhaps
>> avoiding the problem entirely by using MIGRATION_MODULES).
>>
>> I was unclear: What I meant was that a potential solution within the
>> Mezzanine codebase is a monkeypatch which changes the state_forwards
>> method at runtime to comport with the subclass example that I've provided.
> Ah, I see. I didn't realize that you were looking for a generic solution
> in Mezzanine, rather than a solution for your specific Mezzanine-using
> project.
>
>> My question (which at this point probably belongs more on dev than here)
>> is: Which is the most Djangoic approach:
>>
>> 1) Modify the Mezzanine docs to encourage users to take their own
>> action, such as A) using MIGRATION_MODULES or B) manually editing
>> migrations and subclassing the operation in question as I've done
>> 2) Adding a monkeypatch to Mezzanine which automates solution 1B above
>> (ie,

Re: A migration in one app that adds a field to another

2014-11-04 Thread Justin Myles Holmes
Hey Carl.  Missed you so very much at DjangoCon.  :-)

> I'm not sure why the mezzanine docs don't mention using the
SOUTH_MIGRATION_MODULES setting (or Django 1.7 equivalent
MIGRATION_MODULES) to override the location of the mezzanine app's
migrations to a package in your project, where you can freely add custom
migrations without modifying mezzanine code.

While I don't want to speak for Mezzanine (and, frankly, am not crazy
about their approach to field injection in the first place), I surmise
that they want to be able to both ship their own migrations (when their
models change) and allow their users to add their own migrations (for
injecting fields).

As I say, I don't love the solution, but I do see its advantages over
merely providing a mixin, as they have a relationship structure of their
own between their models that they want to maintain.

You say that it's a reasonable tradeoff; I don't think I agree.  For
Django's part, I'm not convinced that, without exception, migrations for
a particular model belong in the same app as that model.  I think there
are reasonable times to place them elsewhere, and this is one of them. 
Another is an occasion in which an organization has its own internal
apps and runs versions of its project without and without a particular
app.  If that app requires an incoming ForeignKey from a model in a
different app, that migration is ideally only implied in the presence of
the target app.

> I don't see any monkeypatch there, just subclassing, which is not the same 
> thing. I'd say that
looks like a very nice solution to the problem. The level of "fiddling
with internals" required seems roughly proportional to the peculiarity
of the use case; I doubt you'll find anything better (other than perhaps
avoiding the problem entirely by using MIGRATION_MODULES).

I was unclear: What I meant was that a potential solution within the
Mezzanine codebase is a monkeypatch which changes the state_forwards
method at runtime to comport with the subclass example that I've provided.

My question (which at this point probably belongs more on dev than here)
is: Which is the most Djangoic approach:

1) Modify the Mezzanine docs to encourage users to take their own
action, such as A) using MIGRATION_MODULES or B) manually editing
migrations and subclassing the operation in question as I've done
2) Adding a monkeypatch to Mezzanine which automates solution 1B above
(ie, a function that takes an Operation object and returns a
OperationOnAnotherApp object)
3) Providing a solution in Django for migrating a model from an app
other than that model's home

On 11/01/2014 09:16 PM, Carl Meyer wrote:
> Hi jMyles,
>
> On 11/01/2014 04:35 PM, jMyles Holmes wrote:
>> Using Django 1.7, how can the user perform a migration operation (say,
>> AddField) on an app other than the app in which the migration lives?
>>
>> Here's the use case:
>>
>> Mezzanine lets you inject fields on its own stock models using the
>> EXTRA_MODEL_FIELDS setting.
>>
>> However, as the Mezzanine docs point out
>>
(http://mezzanine.jupo.org/docs/model-customization.html#field-injection-caveats),
>> there are some "caveats" regarding migrations.
>>
>> Specifically, the migrations need to be placed in a local app even
>> though they're applied to the Mezzanine models.
>>
>> What's the proper way to do this in Django 1.7?
>
> Perhaps someone with more experience with the new migrations system can
> correct me, but I doubt there is a "proper way" - this is an unusual and
> probably unsupported use case that I would guess was never envisioned in
> the design. In general, changes to a model belong in the migrations for
> that model's app.
>
> I'm not sure why the mezzanine docs don't mention using the
> SOUTH_MIGRATION_MODULES setting (or Django 1.7 equivalent
> MIGRATION_MODULES) to override the location of the mezzanine app's
> migrations to a package in your project, where you can freely add custom
> migrations without modifying mezzanine code.
>
> The downside of this approach is that if a new mezzanine version in the
> future ships migrations for changes to their model, you'll have to copy
> or regenerate those migrations yourself in your custom migrations
> directory. That seems like a reasonable tradeoff in the situation where
> you're effectively monkeypatching another app's models.
>
>> It's easy to do it with a monkeypatch.  Here's an example:
>>
>> https://gist.github.com/jMyles/130050563ba96a7d7cc8
>
> I don't see any monkeypatch there, just subclassing, which is not the
> same thing. I'd say that looks like a very nice solution to the problem.
> The level of "fiddling with internals" required seems roughly
> proportional to the peculiarity of the use case; I doubt you'll find
> anything better (other than perhaps avoiding the problem entirely by
> using MIGRATION_MODULES).
>
> Carl
>


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

making an http request internally

2014-10-17 Thread justin
Hey list,

I am writing a middleware class that needs to be able to make HTTP requests 
to the application as part of it's processing. I'd like to be able to do 
this internal to the Django app if possible, rather than having to make 
external requests to the webserver hosting the Django app.

I've discovered that I can use django.core.urlresolvers.resolve to obtain a 
view function for a given URL. Awesome! This gets me /very/ close, but I'm 
missing a couple of things:

1) If I simply call the view function obtained from resolve(), it will be 
executed without middleware. I still want all the usual middleware 
processing to occur though.

2) I'm not sure how to create a fresh HttpRequest object to use for an 
internal request, so my code awkwardly modifies the request object it was 
provided in order to use it for a subrequest. That doesn't feel quite 
proper.

Any tips here would be great. Thanks!

Justin

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4030cd9b-03f9-4274-9183-77a2459ff1ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM Question

2014-04-02 Thread Justin Holmes
I think you misunderstand: I am not actually tracking llama herds. :-)

This is just example code; I haven't actually tested it in the way that you
suggest.  The problem isn't with this code in particular, it's with this
concept in general.  This is a question I have had again and again in the
past few years - this code is just a way to articulate it.

So, in short - no, the code won't work as now written, and it's obvious
why: annotate doesn't assign instances, it assigns results.

I don't think I need an annotation expert per se; it may well be that
annotate is the wrong way to do this.

My SQL isn't particularly strong, but if I were writing this in SQL, I
suspect that GROUP_BY is necessary or at least plausible.  I know that
Django doesn't directly expose GROUP_BY, but it looks likes
QuerySet.values() uses it; so I wonder if that fits into the picture
somehow?


On Wed, Apr 2, 2014 at 12:35 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> My point was that annotate might work after the other problems were
> fixed.  Have you re-tested since?  If your annotate still doesn't work then
> perhaps someone with more annotate experience than I will comment.
>
>
>
> On Wed, Apr 2, 2014 at 12:04 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> No no, the annotate doesn't work - that's the whole reason for my
>> question.  See, the annotate doesn't associate instances with the annotated
>> attribute, it associated results.
>>
>> (BTW, good looking out - I have once again fixed the SO question :-))
>>
>>
>> On Wed, Apr 2, 2014 at 10:17 AM, Bill Freeman <ke1g...@gmail.com> wrote:
>>
>>> 1.  You now have a foreign key to Herd, but you don't have a model by
>>> that name.  It's called LlamaHerd.
>>>
>>> 2.  I was misinterpreting what you wanted (couldn't get past the lack of
>>> a relationship while reading0.  Once the relationship is fixed, your
>>> original annotate might work.
>>>
>>>
>>> On Tue, Apr 1, 2014 at 6:20 PM, Justin Holmes 
>>> <jus...@justinholmes.com>wrote:
>>>
>>>> You say "use the reverse relation manager in LlamaHerd to build up your
>>>> annotation," but that answer the question.
>>>>
>>>> How can I sort LlamaHerd objects by the DOB of their largest llama?
>>>>
>>>>
>>>> On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes 
>>>> <jus...@justinholmes.com>wrote:
>>>>
>>>>> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
>>>>> models to look like:
>>>>>
>>>>> class LlamaHerd(models.Model):
>>>>> shepherd = ForeignKey(User)
>>>>>
>>>>> class Llama(models.Model):
>>>>> size = FloatField()
>>>>> dob =
>>>>>  FloatField
>>>>> herd = ForeignKey(Herd, related_name="llamas")
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com>wrote:
>>>>>
>>>>>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd
>>>>>> a Llama belongs to?
>>>>>>
>>>>>> Then you would use the reverse relation manager in LlamaHerd to build
>>>>>> up your annotation.
>>>>>>
>>>>>>
>>>>>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <
>>>>>> jus...@justinholmes.com> wrote:
>>>>>>
>>>>>>> I have come across this problem in several Django projects, but only
>>>>>>> just now worked it out in my head enough to make it a cognizable 
>>>>>>> question.
>>>>>>>
>>>>>>> I have also posted it on StackOverflow, here:
>>>>>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>>>>>
>>>>>>>
>>>>>>> Consider this example:
>>>>>>>
>>>>>>> class LlamaHerd(models.Model):
>>>>>>> shepherd = ForeignKey(User)
>>>>>>>
>>>>>>> class Llama(models.Model):
>>>>>>> size = FloatField()
>>>>>>> dob = FloatField
>>>>>>>
>>>>>>> How can I now make a query to get LlamaHerd objects, sorted by the
>>>>>>> date of birth of their largest

Re: ORM Question

2014-04-02 Thread Justin Holmes
No no, the annotate doesn't work - that's the whole reason for my
question.  See, the annotate doesn't associate instances with the annotated
attribute, it associated results.

(BTW, good looking out - I have once again fixed the SO question :-))


On Wed, Apr 2, 2014 at 10:17 AM, Bill Freeman <ke1g...@gmail.com> wrote:

> 1.  You now have a foreign key to Herd, but you don't have a model by that
> name.  It's called LlamaHerd.
>
> 2.  I was misinterpreting what you wanted (couldn't get past the lack of a
> relationship while reading0.  Once the relationship is fixed, your original
> annotate might work.
>
>
> On Tue, Apr 1, 2014 at 6:20 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> You say "use the reverse relation manager in LlamaHerd to build up your
>> annotation," but that answer the question.
>>
>> How can I sort LlamaHerd objects by the DOB of their largest llama?
>>
>>
>> On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>>
>>> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
>>> models to look like:
>>>
>>> class LlamaHerd(models.Model):
>>> shepherd = ForeignKey(User)
>>>
>>> class Llama(models.Model):
>>> size = FloatField()
>>> dob =
>>>  FloatField
>>> herd = ForeignKey(Herd, related_name="llamas")
>>>
>>>
>>>
>>>
>>> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>>>
>>>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
>>>> Llama belongs to?
>>>>
>>>> Then you would use the reverse relation manager in LlamaHerd to build
>>>> up your annotation.
>>>>
>>>>
>>>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes 
>>>> <jus...@justinholmes.com>wrote:
>>>>
>>>>> I have come across this problem in several Django projects, but only
>>>>> just now worked it out in my head enough to make it a cognizable question.
>>>>>
>>>>> I have also posted it on StackOverflow, here:
>>>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>>>
>>>>>
>>>>> Consider this example:
>>>>>
>>>>> class LlamaHerd(models.Model):
>>>>> shepherd = ForeignKey(User)
>>>>>
>>>>> class Llama(models.Model):
>>>>> size = FloatField()
>>>>> dob = FloatField
>>>>>
>>>>> How can I now make a query to get LlamaHerd objects, sorted by the
>>>>> date of birth of their largest llama?
>>>>>
>>>>> It almost feels like I might be able to use annotate:
>>>>>
>>>>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>>>>
>>>>> ...but the annotate here creates fields with float values, not with
>>>>> the model instances.
>>>>>
>>>>>
>>>>> --
>>>>> Justin Holmes
>>>>> Chief Chocobo Breeder, slashRoot
>>>>>
>>>>> slashRoot: Coffee House and Tech Dojo
>>>>> New Paltz, NY 12561
>>>>> 845.633.8330
>>>>>
>>>>> --
>>>>> 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 post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop rec

Re: ORM Question

2014-04-01 Thread Justin Holmes
You say "use the reverse relation manager in LlamaHerd to build up your
annotation," but that answer the question.

How can I sort LlamaHerd objects by the DOB of their largest llama?


On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes <jus...@justinholmes.com>wrote:

> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
> models to look like:
>
> class LlamaHerd(models.Model):
> shepherd = ForeignKey(User)
>
> class Llama(models.Model):
> size = FloatField()
> dob =
>  FloatField
> herd = ForeignKey(Herd, related_name="llamas")
>
>
>
>
> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
>> Llama belongs to?
>>
>> Then you would use the reverse relation manager in LlamaHerd to build up
>> your annotation.
>>
>>
>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>>
>>> I have come across this problem in several Django projects, but only
>>> just now worked it out in my head enough to make it a cognizable question.
>>>
>>> I have also posted it on StackOverflow, here:
>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>
>>>
>>> Consider this example:
>>>
>>> class LlamaHerd(models.Model):
>>> shepherd = ForeignKey(User)
>>>
>>> class Llama(models.Model):
>>> size = FloatField()
>>> dob = FloatField
>>>
>>> How can I now make a query to get LlamaHerd objects, sorted by the date
>>> of birth of their largest llama?
>>>
>>> It almost feels like I might be able to use annotate:
>>>
>>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>>
>>> ...but the annotate here creates fields with float values, not with the
>>> model instances.
>>>
>>>
>>> --
>>> Justin Holmes
>>> Chief Chocobo Breeder, slashRoot
>>>
>>> slashRoot: Coffee House and Tech Dojo
>>> New Paltz, NY 12561
>>> 845.633.8330
>>>
>>> --
>>> 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 post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Justin Holmes
> Chief Chocobo Breeder, slashRoot
>
> slashRoot: Coffee House and Tech Dojo
> New Paltz, NY 12561
> 845.633.8330
>



-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB4V3zpbqr7v1kcvOi8%2BoqLPm0nr18dGStaedys494%2BOag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM Question

2014-04-01 Thread Justin Holmes
Yes, absolutely - my bad.  I have updated to SO question.  I meant the
models to look like:

class LlamaHerd(models.Model):
shepherd = ForeignKey(User)

class Llama(models.Model):
size = FloatField()
dob = FloatField
herd = ForeignKey(Herd, related_name="llamas")




On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
> Llama belongs to?
>
> Then you would use the reverse relation manager in LlamaHerd to build up
> your annotation.
>
>
> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> I have come across this problem in several Django projects, but only just
>> now worked it out in my head enough to make it a cognizable question.
>>
>> I have also posted it on StackOverflow, here:
>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>
>>
>> Consider this example:
>>
>> class LlamaHerd(models.Model):
>> shepherd = ForeignKey(User)
>>
>> class Llama(models.Model):
>> size = FloatField()
>> dob = FloatField
>>
>> How can I now make a query to get LlamaHerd objects, sorted by the date
>> of birth of their largest llama?
>>
>> It almost feels like I might be able to use annotate:
>>
>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>
>> ...but the annotate here creates fields with float values, not with the
>> model instances.
>>
>>
>> --
>> Justin Holmes
>> Chief Chocobo Breeder, slashRoot
>>
>> slashRoot: Coffee House and Tech Dojo
>> New Paltz, NY 12561
>> 845.633.8330
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB6r1wu0hsTVH8JdpBMSWDLBWsH87%2B1H_vZ%2BDqr0Eu%2BSXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


ORM Question

2014-04-01 Thread Justin Holmes
I have come across this problem in several Django projects, but only just
now worked it out in my head enough to make it a cognizable question.

I have also posted it on StackOverflow, here:
http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item


Consider this example:

class LlamaHerd(models.Model):
shepherd = ForeignKey(User)

class Llama(models.Model):
size = FloatField()
dob = FloatField

How can I now make a query to get LlamaHerd objects, sorted by the date of
birth of their largest llama?

It almost feels like I might be able to use annotate:

LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')

...but the annotate here creates fields with float values, not with the
model instances.


-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.6 test cases for code which calls transaction.set_autocommit()

2014-03-07 Thread Justin Michalicek


On Friday, March 7, 2014 2:58:29 AM UTC-5, Anssi Kääriäinen wrote:
>
> On Friday, March 7, 2014 12:11:59 AM UTC+2, Justin Michalicek wrote:
>>
>> It appears that due to test cases running in an atomic block, testing 
>> methods which use transaction.set_autocommit() all fail.  I've got a small 
>> handful of test cases around methods which need to use manual transaction 
>> management and they are definitely working when I actually use the site, 
>> but in test cases they all fail and raise the exception 
>> "TransactionManagementError: This is forbidden when an 'atomic' block is 
>> active." at the line where I call transaction.set_autocommit(False)
>>
>> Is there something I'm missing here?
>>
>
> Django's default TestCase runs the whole test inside a transaction, thus 
> code trying to manage transactions fail. The reason for this is that if the 
> tests are ran inside transactions, there is no need to clean up the 
> database after the test, as doing rollback at the end of the test will 
> guarantee clean state. If you need to test transactional code, use 
> TransactionTestCase.
>
>  - Anssi 
>

Ah hah, thanks.  I knew there had to be something I'd overlooked here.  In 
previous versions of Django you could test code which used 
transaction.commit_manually() in a regular TestCase, although I am now 
questioning whether it tested it properly or not.  The fact that this would 
no longer work was not made clear by the Django 1.6 release notes and info 
specifically covering backwards-incompatible changes. 
 

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/48fb929e-9633-4fa0-ba6a-80542c4e46d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.6 test cases for code which calls transaction.set_autocommit()

2014-03-06 Thread Justin Michalicek
It appears that due to test cases running in an atomic block, testing 
methods which use transaction.set_autocommit() all fail.  I've got a small 
handful of test cases around methods which need to use manual transaction 
management and they are definitely working when I actually use the site, 
but in test cases they all fail and raise the exception 
"TransactionManagementError: This is forbidden when an 'atomic' block is 
active." at the line where I call transaction.set_autocommit(False)

Is there something I'm missing here?

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59e318ed-406a-4cb1-ac77-212480816faa%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Why no locale (formats.py) for Australia en_AU or Canada en_CA?

2013-08-30 Thread Justin Hill
https://github.com/django/django/tree/master/django/conf/locale

Does anyone have an idea as to why Australia doesn't have a locale format? 
 en_GB is there, but no en_CA, or en_AU.  My code is in seven countries and 
my forms are working in all of them except Australia and Canada.  It's 
looking for an en_AU format folder that doesn't exists and falling back to 
the defaults.  My users wonder why they can't enter dates in their native 
date format.

Translations are working for things that are different like US: 'zip code', 
CA: 'postal code', AU: 'postcode'

Same would apply to Canada en_CA. But they aren't complaining because their 
date format matches the default -mm-dd.

I'm going to go the route of making my own format file 
(https://docs.djangoproject.com/en/dev/topics/i18n/formatting/#creating-custom-format-files),
 
but just seems odd that this would be necessary for such well known 
countries.

Am I doing it wrong?

Justin

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Conneting Sybase ASE using pyodbc in Django

2013-08-06 Thread Justin Thorsen
I've been searching for days on this topic.  So far no...there does not 
exists anyway to connect sybase ase with django in any shape or form.  I 
will however being attempting to build one for the next two weeks.  As of 
right now the plan is to modify django-pyodbc to be compatible with pybase 
ase even if it compromises its previous compatibility with anything that 
isnt sybase ase.

- Justin

On Wednesday, September 8, 2010 9:12:49 PM UTC-5, Ivan wrote:
>
> I wonder any one is conneting Sybase ASE using pyodbc in Django? Any
> wrapper available for that? Any solution?
>
> Currently there are:
> - sqlany-django (http://code.google.com/p/sqlany-django/) for Sybase
> SQL Anywhere and not Sybase ASE
> - django-pyodbc (http://code.google.com/p/django-pyodbc/) for MS SQL
> Server through pyodbc
>
> Thanks.
>
> Ivan
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Uploading file and serving them with CDN - Best practices

2013-08-06 Thread Justin Michalicek
It's pretty straightforward to get django to automatically upload 
everything to s3 using https://github.com/qnub/django-boto/
I've only used it to server directly from s3, but it sounds like you might 
want to upload to s3 and then serve from cloudfront.  cloudfront uses edge 
servers to serve content from a nearby location whereas s3 does not.  
Slightly different configuration is needed to server from cloudfront, but I 
imagine it's not terribly difficult.

On Tuesday, August 6, 2013 12:19:12 PM UTC-4, Guy Tamir wrote:
>
> Hi all,
>
> My question is not a pure Django question, but since i'm working with 
> django and there are probably people here with experience i'll try anyway..
>
> I'm working on an app that runs on 2 servers, the first is a management 
> server where my users in certain page can upload images\videos to my server.
> The second server, among other things, shows the videos\images uploaded by 
> the users..
>
> I know Django has a form object that helps with the uploading part, my 
> question is what is the best practice regarding what to do with the files?
>
> One server is running on Heroku, the second on Amazon EC2.
>
> Should I save the files on the Heroku server and using ssh copy to the EC2 
> and serve from there 
> or should i just upload directly to Amazon S3 (or another storage service) 
> and serve the content directly from the S3?
>
> Should keep in mind that i'll want to use a CDN service (not sure if this 
> matters) 
>
> I've never hacked something like this so i'm not sure whats the common 
> practice and where to start...
>
> Best regards,
> Guy
>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django installation on vanilla Mac OSX 10.8.2 mountain lion

2013-08-02 Thread Justin Michalicek
I install it on my Mac running 10.8.4 using pip on a pretty regular basis 
for starting new projects and testing things.  I use postgres from 
homebrew, virtualenv and virtualenvwrapper installed as system packages, 
then install django as needed into virtualenvs using pip.

On Friday, August 2, 2013 10:41:35 AM UTC-4, Lloyd Dube wrote:
>
> Hi everyone,
>
> I just began using a new Mac at work (running OSX 10.8.2 Mountain Lion) 
> and it seems such a mission to install Django. Python 2.7.2. is already 
> installed. Following the official Django installation instructions, I get 
> no further than trying to get wget-> which I will ned to compile with a C 
> Compiler -> which I can get by downloading 1+ gigs of xCode. Really?
>
> Could somebody please point out a safe and straight-forward way to install 
> Django on Mountain Lion?
>
> Thanks.
>
> -- 
> Regards,
> Sithu Lloyd Dube 
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django workaround for multiple primary keys or sqlalchemy

2013-07-29 Thread Justin Michalicek
I would go with the Django ORM and just add a unique_together for a 
multiple column uniqueness constraint.  That index won't be your primary 
key, but it will still be a unique index.  I've even gone as far as to use 
custom .sql files (which manage.py syncdb runs) and custom sql in South 
migrations to create highly customized things like a partial unique index 
(a Postgres specific thing) when necessary.

Going with SQLAlchemy is probably asking for trouble, especially if you're 
new both Django and SQLAlchemy.  Swapping SQLAlchemy in for the Django ORM 
was more common early in Django's lifetime when its ORM was not as robust 
as it is today.  By doing so you'll lose a number of things that currently 
"just work", which to me is one of strengths of Django - these things were 
made to work together and so I know they will work and will continue to 
work.  I suspect using SQLAlchemy is going to cause issues if you try to 
use any 3rd party Django apps as well.

On Monday, July 29, 2013 11:39:20 AM UTC-4, Guy Tamir wrote:
>
> Hi all,
>
> i'm fairly new to Django and i have a question regarding the best practice 
> for a situation i've got.
>
> I'm working on a new project and after designing my ERD I know i need a 
> few tables to have multiple primary keys and one table with triple primary 
> keys.
>
> after reading about the subject online i found out that Django does not 
> support this feature yet but there is a workaround which is to add a 
> unique_together constraint (if i understand correct)
> reading some more online there are recommendations for working with 
> SQLAlchemy that does support the multiple primary key issue.
>
> I have 2 questions regarding those issues:
> 1. if I use the django workaround will it later bite me in the ass 
> performance wise and simply by not working correctly?
> 2. if i'll work with SQLAlchemy does that mean that i wont be able to work 
> with django models and all that is derived from working like so?
>
> whats the recommended practice for my situation?
>
> Thanks all..
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django count

2013-07-28 Thread Justin Michalicek
It looks like maybe a slight change to your models and schema would make 
this a bit cleaner if I'm understanding your overall schema correctly.  I 
would split this up into two different models with a ManyToMany 
relationship in there.  I am assuming you have students and then an Egitim 
instance is one instance of a student taking one class, correct?

class Student(models.Model):
first_name = models.CharField(max_length=200)
surname =  models.CharField(max_length=20)
email = models.EmailField(max_length=75)
courses = models.ManyToManyFIeld('Course', blank=True)

class Course(models.Model):
course_name =  models.CharField(max_length=300)

Then if you need the count you can do one of these:
student = Student.objects.get(email=email_address)
student.courses.all().count()

Course.objects.filter(student__email=email_address).count()


On Sunday, July 28, 2013 8:06:28 AM UTC-4, Murat Bilal wrote:
>
> Hi all,
> I have a model like this
> class Egitim(models.Model):
> name = models.CharField(max_length=200)
> surname =  models.CharField(max_length=20)
> email = models.EmailField(max_length=75)
> course_name =  models.CharField(max_length=300)
> num_of_courses_taken = models.IntegerField(max_length=100)
> def __unicode__(self):
>   return self.course_name
>  
> class EgitimForm(ModelForm):
> class Meta:
>   model=Egitim
>   fields=('name','surname','email','course_name')
> I want to increment num_of_courses_taken value according to email 
> addresses.For example if there are 3 aa@example .com mail is submitted in 
> ModelForm.it means the user aa have taken 3 courses.
>  
> Please Help
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Http404 and process_exception

2012-03-30 Thread Justin Holmes
Russell,

Yeah, I see the inconsistency there, and my first thought was that
this is a bit backward.  However, the underlying distinction here is
that it's not the 404 (ie, the resource gone missin') that is the
exception but the Http404 object.

It remains straightforward enough for a developer to simply return
HttpResponseNotFound if they don't want their business logic treated
as an exception.

(Maybe this belongs on -dev) I do, however, think that the
get_object_or_404 documentation can be clearer that, as with .get(),
either failing case raises an exception.  Perhaps change the note to:

"As with .get(), an exception is raised unless exactly one object is
found for the given parameters.  A MultipleObjectsReturned exception
will be raised if more than one object is found.  However, unlike
.get(), Http404 is raised if no object is found."

This may not be necessary at all, as the Http404 page makes it clear
that it's an exception.



On Wed, Mar 28, 2012 at 7:22 PM, Russell Keith-Magee
<russ...@keith-magee.com> wrote:
>
>
> On 29/03/2012, at 12:10 AM, Justin Holmes wrote:
>
> > Russell,
> >
> > Thanks for the reply.
> >
> > Two reasons:
> >
> > 1) Up until now, I hadn't encountered a 404 that had triggered this 
> > particular process_exception.  It hadn't occurred to me that since 
> > get_object_or_404 actually raises the Http404 exception that the behavior 
> > was going to be different than, say, a try block whose exception clause 
> > returned HttpResponseNotFound.
> >
> > 2) Once I had encountered this phenomenon, a quick google search led me to 
> > this page from the book:
> >
> > http://www.djangobook.com/en/beta/chapter16/
> >
> > which seemed, at least for a moment, to verify my previous experience.
>
> Yes - that does seem to suggest 404's don't trigger exception middleware. 
> However, I've checked the code back to the magic-removal merge (in 2005) [1], 
> and I can't see any evidence that 404's have ever been a special case.
>
> [1] 
> https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py?rev=2809#L73
>
> The only change to this area that I can see is to make sure that the response 
> raised by the exception middleware is in recent times has been a modification 
> that means that if the exception middleware returns a response, that response 
> goes through the response middleware; back in the days of magic-removal, it 
> would be returned verbatim.
>
> > I think though that I simply hadn't raised Http404 since implementing this 
> > middleware.  It makes perfect sense that it behaves the way it does.
>
> Yes and no; yes, in that it's an exception; no, in that it's an interesting 
> inconsistency that 404s are (or can be) handled as exceptions, but no other 
> status code is handled as an exception.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



--
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Http404 and process_exception

2012-03-28 Thread Justin Holmes
Russell,

Thanks for the reply.

Two reasons:

1) Up until now, I hadn't encountered a 404 that had triggered this
particular process_exception.  It hadn't occurred to me that since
get_object_or_404 actually raises the Http404 exception that the behavior
was going to be different than, say, a try block whose exception clause
returned HttpResponseNotFound.

2) Once I had encountered this phenomenon, a quick google search led me to
this page from the book:

http://www.djangobook.com/en/beta/chapter16/

which seemed, at least for a moment, to verify my previous experience.

I think though that I simply hadn't raised Http404 since implementing this
middleware.  It makes perfect sense that it behaves the way it does.



On Tue, Mar 27, 2012 at 11:29 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
> On 28/03/2012, at 6:31 AM, Justin Holmes wrote:
>
> > Heretofore, I had always believed that Http404 did not cause Middleware
> process_exception() to be run.  Am I right in this thinking?
> >
> > I have a get_object_or_404 that, when the object in question isn't
> found, is running process_exception.
>
> Http404 is an exception, so yes, it should cause process_exception() to be
> run.
>
> The test suite for middleware processing might be (slightly) illuminating
> here; it's a bit long winded and gnarly, but it enumerates and validates
> the full path for every possible combination of middleware and response
> type.
>
> Look at regression_tests/middleware_exceptions;
> test_process_exception_middleware_not_found is the test for your specific
> case.
>
> Out of interest -- can you put your finger on why you heretofore thought
> Http404 didn't hit exception middleware? I've done a quick poke through the
> history of the middleware handling code, and I can't see any obvious reason
> why this would have changed (even inadvertently).
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Http404 and process_exception

2012-03-27 Thread Justin Holmes
Heretofore, I had always believed that Http404 did not cause Middleware
process_exception() to be run.  Am I right in this thinking?

I have a get_object_or_404 that, when the object in question isn't found,
is running process_exception.


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New way to run your Django projects

2012-03-18 Thread Justin Holmes
I feel the need to inject, once again, that the Twisted WSGI container
rocks.

On Sun, Mar 18, 2012 at 12:40 PM, Bolang <boo.l...@gmail.com> wrote:

> Hi Alexander,
> What is the advantage of using gevent-fastcgi instead of simply using
> nginx and maybe with gunicorn?
>
>
>
> On 03/18/2012 12:59 PM, Alexander wrote:
>
>> Hello everybody,
>>
>> I'm working on gevent coroutine based  library FastCGI server
>> implementation and I's ready for testing. It most likely contains lots
>> of bugs and it would be great if you help to catch some of them.
>>
>> Just install gevent-fastcgi package:
>>
>> $ easy_install gevent-fastcgi
>>
>> Then include gevent_fastcgi.adapters.django into INSTALLED_APPS list
>> of your settings.py. Then run:
>>
>> $ python manage.py run_gevent_fastcgi host:port
>>
>> Run "python manage.py run_gevent_fastcgi --help" to find out more
>> about run_gevent_fastcgi command.
>>
>> Alex
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: question about "\d" in url pattern

2012-02-27 Thread Justin Myers
On Feb 27, 1:44 am, Masklinn  wrote:
> On 27 févr. 2012, at 07:23, Zheng Li  wrote:
> > i thought "\d+" in url promises i can get an int point in cheer_confirm, 
> > and am i wrong?
>
> \d+ ensures you will only get naturals, but django will not perform any 
> conversion automatically. Especially not here as it would require 
> introspecting the regular expression to see which pattern was matched and 
> whether it is convertible.

This is also in the docs: 
https://docs.djangoproject.com/en/1.3/topics/http/urls/#notes-on-capturing-text-in-urls

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-deeper

2011-12-28 Thread Justin Holmes
In response to the recent discussion of SOPA on the django-dev list
(and to the recurring phenomenon of having no clearly defined space to
congregate to discuss "deeper" issues), I have started a new google
group, django-deeper.

As a relative newcomer to the django community, I have been
overwhelmed by the awesome vibes.  Djangocon 2011 was one of the best
conferences (probably top 5 even) that I've ever been to.

>From the very first peek at the project, it's clear that django has a
much sharper focus on community building than is typical for a
software project.  The emphasis and effort on documentation, for
example, sends a strong signal that "this is not just a piece of
software, it's a group of passionate people."  The mature and
open-minded atmosphere of the django IRC presence also suggests this.

As the django community expands in breadth and in depth, we need a way
to ensure that our underlying aspirations - expressed sometimes in the
form of python code but sometimes as political, philosophical, or
psychological prose, are likewise cultivated.  My hope is that
django-deeper will provide a forum for those of us who welcome growth
in this direction.

http://groups.google.com/group/django-deeper

-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django.conf.urls.defaults.url documentation

2011-11-15 Thread Justin Myers
Docs are here: https://docs.djangoproject.com/en/1.3/topics/http/urls/#url
-Justin

On Nov 14, 11:59 pm, Mike Thon <mike.t...@gmail.com> wrote:
> I recently started working on a new Django project using the latest
> release, and I found the function django.conf.urls.defaults.url being used
> in urls.py.  There's no pydoc documentation for this function.  Can anyone
> tell me what it does or point me to some documentation?
>
> thanks
> Mike

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: point url with folder to s3

2011-11-13 Thread Justin Steward
On Mon, Nov 14, 2011 at 8:47 AM, ydjango <neerash...@gmail.com> wrote:
> I have all my static being served from https://www.example.com/media/
>
> in my code I have all images pointing to /media all over the code.
> for example: 
>
> Is there a way I can point it to use S3 and cloudfront to serve the
> static files.
>
> My understanding is that I cannot use CNAME. If I was using
> media.example.com instead of www.example.com/media, I could have used
> CNAME.
>
> Any other solution? (without requiring me to change all the instances
> of /media in all my code)
>
> I use nginx and apache and django 1.1.x. (I will be upgrading Django
> soon if ORM performance does not become an issue.)
>

If updating the code is out of the question, then why not put a
redirect into the apache or nginx conf, something along the lines of
(untested, for nginx. Look up modrewrite to do this in your apache
conf):

server {
  listen 80;
  server_name www.example.com;
  rewrite /media/(.*)
http://domain.of.external.media.com/path/to/media/$1 permanent;
  # the rest of your nginx conf here
}

And then take your time to replace references to /media in your code,
because you really should anyway.

You should probably be using a variable in your code for media
location in the future, so you only have to change /media once. Isn't
there a variable in the settings explicitly for the url of static
media?

~Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



contrib.auth tests - not respecting TEMPLATE_DIRS?

2011-10-10 Thread Justin Holmes
I'm running the contrib.auth tests in a situation where I have a
signal hook on login which uses a template.

Strangely, when I run the full test suite, I find that in state, the
global template dirs contains only
"/django/contrib/auth/tests/templates" and not the directory (or -ies)
specified in the TEMPLATE_DIRS setting.

The same code is executed just fine in production.

-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



test_invalid_key failing

2011-10-04 Thread Justin Holmes
I am having a problem with contrib.sessions.tests.test_valid_key (line
159).  It's a mixin which in the failure case is mixed with
CacheDBSessionTests.

The test raises:

"AttributeError: 'bool' object has no attribute 'get'"

The error is actually raised by session.save() on 164.

Stepping inward reveals that sessions.backends.cached_db (line 18)
sets data thusly:

data = cache.get(self.session_key, None)

QUESTION #1 (maybe more suited for django-dev?): If I step in, I find
that debugging core.cache.backends.locmem.LocMemCache.get(), which is
odd since the TestCase is CacheDBSessionTests.  Why is it testing
LocMemCache and not core.cache.backends.db.DatabaseCache?

In this case, self.session_key is 1, and indeed the cache has a
pickled "True" for the key 1.  In fact, during the course of debugging
core.cache.backends.locmem.LocMemCache.get(), we have found that in
every case during which the testrunner hits this method, 1 is a key
for pickled True.

QUESTION #2: Why is the key 1 set to a pickled True?

In this case, that True ends up being returned in
contrib.sessions.backends.base.SessionBase.get() (line 64).

Thus, of course an error is raised.  We are unable to understand why
the key 1 is set to pickled True in the locmem backend.

NOW THE STRANGE PART:

Iff we step in with a debugger and wait for > 3 seconds or so, the
method no longer returns True and instead returns an empty dict.  In
this case, the test passes!

We are baffled.  Is this possibly an underlying race condition or
hotel room scenario (http://stackoverflow.com/questions/6441218)?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: is photologue still maintained?

2011-09-17 Thread Justin
Hey,

I'm the original dev of both Photologue and ImageKit. ImageKit is
being actively maintained but I'm not using Photologue in any projects
anymore so it's hard to find time to keep it up. The next version was
planned to be a complete break, as in not backwards compatible, and
based on ImageKit. You can check that out here:

https://bitbucket.org/jdriscoll/django-photolog

I would love for someone who uses PL to take over the project but so
far I haven't found anyone suitable.

-- Justin

On Sep 16, 2:00 am, graeme <graeme.piete...@gmail.com> wrote:
> It may or may not help you, but ImageKit seems actively maintained:
>
> https://github.com/jdriscoll/django-imagekit
>
> http://groups.google.com/group/django-photologue/browse_thread/thread...
>
> As far as I understand it, a new version of Photologue was planned,
> which would be based on Imagekit. I have no idea whether that happened
> or not.
>
> As far as I can see the original developer seems to be inactive on
> both projects.
>
> On Sep 16, 2:02 am, bedros <2bed...@gmail.com> wrote:
>
>
>
>
>
>
>
> > any idea who's maintaining photologue and if still has a support
> > community? and which fork repo supports the latest django release,
> > there are bunch of forks on  googlecode, github, bitbucket?
>
> > Thanks,
>
> > Bedros

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Abstract base classes, multiple inheritance and field removal

2011-05-26 Thread Justin
Hello All,

I have a situation where I would like to combine two fields from two
abstract child classes into a parent class.

class A(model):
field = MyField()

class Meta:
abstract = True

class B(model):
field = MyField()

class Meta:
abstract = True

class C(A, B, model):
pass


It is stated explicitly in the documentation that this cannot be done,
but I'd like to know if that's necessarily true.

In a class decorator or metaclass which works up class C, the
following can be done:


fields = [f for f in cls._meta.fields if isinstance(f, MyField)]
keep_field = fields.pop()

for field in fields:
cls._meta.local_fields.remove(field)
del cls._meta._field_name_cache


This seems to work great for me. But I'd like to know what side
effects there might be in working up the internal machinery of the
model class this way. If this is not a good way to remove fields, is
there another?

thanks,

Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django custom template tags: how to send to (parser, token)

2011-03-30 Thread justin jools
I've just started using custom tags and need some help parsing info
to:

@register.tag
def friends_of(parser, token):
tag_name, user_var = token.split_contents()
return FriendsOfNode(user_var)

class FriendsOfNode(template.Node):
def __init__(self, user_var):
self.user_var = template.Variable(user_var)

def render(self, context):
user = self.user_var.resolve(context)
context.update({'friends': Friendship.objects.friends_of(user,
True)})
return u''

I tried:

friends: {% friends_of {{ user }} %}

output:

ValueError at /friends/

too many values to unpack

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django Notification - can't send notifications

2011-03-28 Thread justin jools
can't send notifications

have tried adding (in notification models.py):

if notification:
   notification.send([self.from_user], "friends_accept",
{"invitation": self, "new_user": self.to_user})

but does nothing although I can enter notices manually in admin.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-simple-friends + notifications: how to intergrate?

2011-03-28 Thread justin jools
I have both simple-friends and notifications running and workign and
have set up notice types.

How do I use signals from friend request for instance to trigger
notice types?

examples

simple-friends:

class FriendshipRequest(models.Model):
from_user = models.ForeignKey(User,
related_name="invitations_from")
to_user = models.ForeignKey(User, related_name="invitations_to")
message = models.CharField(max_length=200, blank=True)
created = models.DateTimeField(default=datetime.datetime.now,
   editable=False)
accepted = models.BooleanField(default=False)

class Meta:
verbose_name = _(u'friendship request')
verbose_name_plural = _(u'friendship requests')
unique_together = (('to_user', 'from_user'),)

def __unicode__(self):
return _(u'%(from_user)s wants to be friends with %
(to_user)s') % \
{'from_user': unicode(self.from_user),
 'to_user': unicode(self.to_user)}

def accept(self):
Friendship.objects.befriend(self.from_user, self.to_user)
self.accepted = True
self.save()
signals.friendship_accepted.send(sender=self)

def decline(self):
signals.friendship_declined.send(sender=self, cancelled=False)
self.delete()

def cancel(self):
signals.friendship_declined.send(sender=self, cancelled=True)
self.delete()

notifications:

 
notification.send(Friendship.objects.friends_for_user(self.owner.id),
"listing_new", {'listing':self, }, )

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: simple friends template help

2011-03-28 Thread justin jools
thing here
> > {%endifequal%}
>
> > {% ifequal friend.is_invited %}
> > something else
> > {%endifequal%}
>
> > On Mar 27, 7:32 pm, justin jools <devhe...@gmail.com> wrote:
> > > need some help setting up templates for friends list:
>
> > > how do I iterate a list of invited friends and are friends? I have
> > > tried:
>
> > >   {% for friends in Friendship.objects.are_friends %}
>
> > >          target_user: {{ friends.target_user}}
> > >          current_user:{{ friends.current_user}}
> > >          are_friends: {{ friends.are_friends}}
> > >          is_invited: {{ friends.is_invited}}
>
> > >   {% endfor %}
>
> > > gives me nothing but:
>
> > >     {{ is_invited }}
> > >     {{ are_friends }}
> > >     {{ target_user }}
> > >     {{ current_user }}
>
> > > output:
>
> > > false
> > > false
> > > name
> > > name
>
> > > I have been trying to figure this out for months. Please help.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> Can you show us the code that produces these values?
>
> --
> Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: simple friends template help

2011-03-28 Thread justin jools
I now have a different overriding problem with this simple-friends
app:

url patterns are simple:

urlpatterns = patterns('friends.views',
url(r'^$',
'friend_list',
name='friends_home'),
url(r'^list/(?P\w+)/$',
'friend_list',
name='friend_list'),
url(r'^add/(?P\w+)/$',
'friendship_request',
name='friendship_request'),
url(r'^accept/(?P\w+)/$',
'friendship_accept',
name='friendship_accept'),
url(r'^decline/(?P\w+)/$',
'friendship_decline',
name='friendship_decline'),
url(r'^cancel/(?P\w+)/$',
'friendship_cancel',
name='friendship_cancel'),
url(r'^delete/(?P\w+)/$',
'friendship_delete',
name='friendship_delete'),
url(r'^block/(?P\w+)/$',
'block_user',
name='block_user'),
url(r'^unblock/(?P\w+)/$',
'unblock_user',
name='unblock_user'),
)

but when I try /friends/add/jo

I get:

DoesNotExist at /friends/add/jo/

Friendship matching query does not exist.

Request Method: GET
Request URL:http://127.0.0.1:8000/friends/add/jo/
Django Version: 1.3 pre-alpha
Exception Type: DoesNotExist
Exception Value:

Friendship matching query does not exist.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-simple-friends template help

2011-03-27 Thread justin jools
need some help setting up templates for friends list:

how do I iterate a list of invited friends and are friends? I have
tried:


  {% for friends in Friendship.objects.are_friends %}

 target_user: {{ friends.target_user}}
 current_user:{{ friends.current_user}}
 are_friends: {{ friends.are_friends}}
 is_invited: {{ friends.is_invited}}

  {% endfor %}

gives me nothing but:

{{ is_invited }}
{{ are_friends }}
{{ target_user }}
{{ current_user }}


output:

false
false
name
name

I have been trying to figure this out for months. Please help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



simple friends template help

2011-03-27 Thread justin jools
need some help setting up templates for friends list:

how do I iterate a list of invited friends and are friends? I have
tried:


  {% for friends in Friendship.objects.are_friends %}

 target_user: {{ friends.target_user}}
 current_user:{{ friends.current_user}}
 are_friends: {{ friends.are_friends}}
 is_invited: {{ friends.is_invited}}

  {% endfor %}

gives me nothing but:

{{ is_invited }}
{{ are_friends }}
{{ target_user }}
{{ current_user }}


output:

false
false
name
name

I have been trying to figure this out for months. Please help.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: max recursion depth exceeded

2011-01-13 Thread Justin Murphy
Hi vamsy,
Can you post your urls.py files? Perhaps you have a recursive inclusion.

Example:
myapp.urls.py

patterns = urlpatterns('',
url(r'^/', include('myapp.urls') # this will result in a recursive 
inclusion.

)

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: empty DateTimeField?

2011-01-13 Thread Justin Murphy
Good to hear! Thats a common problem; you need to remember that your models 
might not reflect the constraints of the database once you make changes.

Take a look at South for database migrations. It's not too hard to use once 
you get used to the workflow.

http://south.aeracode.org/

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Meaning for this error

2011-01-13 Thread Justin Murphy
Are you using the Django python shell? That error means that your 
environment doesn't point to a settings file, which is handled by the Django 
shell.

Execute this command within your project directory (wherever you have the 
manage.py file):
python manage.py shell

It will open a Python interpretor that automatically loads your project 
settings, installed apps, and other Django infrastructure.

Also, make sure that Django installed on your pythonpath.

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Class based views and form processing

2011-01-12 Thread Justin Murphy
Thanks, Skylar. You're right, it worked. Now I am just shaking my head and 
saying "next time, I'll just read the source..."

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Class based views and form processing

2011-01-12 Thread Justin Murphy
Hi, I still haven't found an answer to this problem so I am shamelessly 
bumping the last updated date.

Thanks in advance for your help!

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: empty DateTimeField?

2011-01-11 Thread Justin Murphy
Did you create a new DB and run syncdb or is it the same DB based on the old 
schema?

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: empty DateTimeField?

2011-01-11 Thread Justin Murphy
Yes. A quick read of the Model Field Reference docs would have answered 
this.

my_date = models.DateTimeField(blank=True, null=True).

http://docs.djangoproject.com/en/dev/ref/models/fields/

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Class based views and form processing

2011-01-10 Thread Justin Murphy
Thanks, Łukasz. I looked into overriding that method too, but it seems like 
there should be a cleaner way. I almost feel like the ``ModelFormMixin`` 
should have an API similar to a ``ModelAdmin`` where one could override a 
``save_model()`` method on the subclass.

The ``form_valid()`` method does a lot of work that could be separted out 
(granted I don't know if more methods to override is a good thing!). The 
docs say that the method "saves the form instance, sets the current object 
for the view, and redirects to 
get_success_url()<http://docs.djangoproject.com/en/dev/ref/class-based-views/#django.views.generic.edit.ModelFormMixin.get_success_url>
."[1]

This might just be semantics, but in my mind the validation of the form and 
the saving of the form should be separated. Let's see if anybody else has 
some input and if not then I will bring this over to django-developers 
and/or IRC.

[1] 
http://docs.djangoproject.com/en/dev/ref/class-based-views/#django.views.generic.edit.ModelFormMixin.form_valid

Thanks,
Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Curious 500 errors

2011-01-10 Thread Justin Murphy
Hi Conor,

You might be running into a CSRF protection error. Django expects a
CSRF token for all POST requests and the MailChimp webhooks aren't
sending one. You will need to decorate your views as @csrf_exempt in
order for them to work. Just make sure that you do some extra
validation on your part for security issues.

Example:
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def handle_mailchimp_callback(request):
   ...

Here is a link to the Django CSRF documentation:
http://docs.djangoproject.com/en/dev/ref/contrib/csrf/?from=olddocs#exceptions

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Class based views and form processing

2011-01-09 Thread Justin
Hello,

I am experimenting with the new class based views coming in 1.3 and am
having trouble figuring out when/where to put this code. I want to
populate a model's created_by field with the user of the current
request.

In the old views, I would have done something this:
obj = form.save(commit=False)
obj.created_by = request.user
obj.save()

Now I am using a generic CreateView class:
class ListCreateView(CreateView):
model = List
form_class = ListForm

I tried supplying an initial data dictionary by overriding
get_initial(), but this doesn't work because the `created_by` field
has editable=False so the form doesn't include it in the fields list.

Am I missing something simple? Probably :). Any help would be greatly
appreciated!

Thanks,
-Justin



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OpenToken Spec & Single Sign On

2011-01-07 Thread Justin
Well that doesn't seem like much fun! But you're right, that's what
will eventually happen.

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OpenToken Spec & Single Sign On

2011-01-07 Thread Justin
Matteo,

Thanks for the response. I wish I could just use the
django.contrib.auth authentication mechanisms and be done with this.
However, I am not looking to use OpenToken to authenticate users in
Django, per se.

I will be making a Django app that accepts an authentication assertion
from another system, packages it into an OpenToken, and then forwards
it on to another system. The target system only accepts OpenToken for
SSO.

My Django application doesn't need to store User information nor
authenticate the user. It is just a translator between one identity
assertion and the other. The end-user won't even know they hit my
Django app as their HTTP requests will just pass right through via
redirects. It's just magic to them.

I am already porting the perl module to python but am running into
issues with the KeyGenerator class. Luckily the original devs provided
plenty of good tests so I know when I am on the right track. I hope to
open source the code once I am done.

Thanks,
Justin


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



OpenToken Spec & Single Sign On

2011-01-06 Thread Justin Murphy
Hello group,

Does anybody have experience with the OpenToken specification? It is
an authentication token that some (not many) applications use for SSO.

I found existing Perl module that encrypts and decrypts the token but
I need a Python version to use in a Django project. Not much luck
finding one on Google, so I am asking this group to see if anybody has
done this before so I don't need to re-create the wheel.

Here is a link to the specification - website will automatically try
and download PDF, sorry :(
http://www.pingidentity.com/support-and-downloads/download.cfm?item=11703

OpenToken Perl module on GitHub:
https://github.com/bleargh45/crypt-opentoken/

I appreciate your help!

Thanks,
Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Any Django framework command to freeze/wait/notify ?

2011-01-05 Thread Justin
+1 for Celery. For Django integration, see django-celery:
https://github.com/ask/django-celery

-Justin

On Jan 5, 2:21 am, vivek_12315 <vivekchauras...@gmail.com> wrote:
> Hi all,
>
> This is a common scenario which many of you have faced.
>
> Say, I created a simple view file, in which user uploads a file and
> does some processing at backend and after processing is finished I am
> rendering a html page with some processed result.
>
> My problem is that, there should be some kind of a mechanism, by which
> I can notify user that "processing is going in background, so please
> wait till the processing finished."
>
> So, what are the easy to implement options I have ? Does Django
> provides something for these scenario ? Will javascript (timer
> mechanism) work ?
>
> Comment/suggestions ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Multi-tenant Django w/ Multi-DB?

2011-01-05 Thread Justin
Have you looked at the Sites framework? You could have multiple
tenants using one database and use a ForeingKey to a Site object to
structure the data. This will result in more complex queries, but
might be less of a cost than the maintenance issues (see below).

If you continue reading that IBM document, the "Database
Considerations" section strongly urges you not to pursue the multiple-
tenants, multiple-databases model due to the inherent maintenance
overhead.

http://www.ibm.com/developerworks/cloud/library/cl-multitenantsaas/#N10210

If you end up finding a good solution to this hairy problem, please
post it. I'd be interested to see what you come up with.

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django-Facebook (yet another thread)

2010-12-15 Thread Justin Murphy
Facebook published a sample GAE application. The code is pretty
straightforward and you can pretty much use the same concepts in your
Django code. I would think that the signed request logic would work
best in middleware.

https://github.com/facebook/runwithfriends

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-registration vs django-account + django-url | opinions?

2010-09-23 Thread justin jools
I have tried out django-registration and liked the simplicity of it,

but following the pinax project, (and using their apps to instruct my
own build) I see they use:

django-account which also requires django-url

I have started just started playing with it and was wondering if
anyone has any opinions of using django-account over django-
registration?
Is one more flexible/has more features?

Pinax must have some reason for choosing this app over the impressive
django-registration

appreciate your feedback


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



InterfaceError at /admin/ Error binding parameter 1 - probably unsupported type.

2010-09-23 Thread justin jools
Have searched everywhere for solution to this error (below) when
loggin in to admin

I also get this error during form post rediect, thinking it it
something to do with intalled apps/middleware or post setting maybe
but dont know what. Anyone come across this? Many Thanks


InterfaceError at /admin/
Error binding parameter 1 - probably unsupported type.Request Method:
POST

Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3 pre-alpha
Exception Type: InterfaceError
Exception Value: Error binding parameter 1 - probably unsupported
type.
Exception Location: C:\Python26\lib\site-packages\django\db\backends
\sqlite3\base.py in execute, line 200
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3 pre-alpha
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.messages',
 'django.contrib.admin',
 'registration',
 'notification',
 'messages',
 'templatetags',
 'account',
 'django_openid',
 'openid',
 'announcements',
 'basic_profiles',
 'signup_codes',
 'authsub',
 'autocomplete_app',
 'uni_form',
 'core',
 'emailconfirmation',
 'about']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django_openid.consumer.SessionConsumer',
 'account.middleware.LocaleMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'pagination.middleware.PaginationMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
  207. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\utils\decorators.py" in
_wrapped_view
  76. response = view_func(request, *args,
**kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
inner
  189. return self.login(request)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  69. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
login
  342. login(request, user)
File "C:\Python26\lib\site-packages\django\contrib\auth\__init__.py"
in login
  69. user.save()
File "C:\Python26\lib\site-packages\django\db\models\base.py" in save
  434. self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in
save_base
  542. created=(not record_exists), raw=raw,
using=using)
File "C:\Python26\lib\site-packages\django\dispatch\dispatcher.py" in
send
  162. response = receiver(signal=self, sender=sender,
**named)
File "C:\django\pinax_rip\apps\account\models.py" in create_account
  67. account, created =
Account.objects.get_or_create(user=instance)
File "C:\Python26\lib\site-packages\django\db\models\manager.py" in
get_or_create
  135. return self.get_query_set().get_or_create(**kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py" in
get_or_create
  373. obj.save(force_insert=True, using=self.db)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in save
  434. self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File "C:\Python26\lib\site-packages\django\db\models\base.py" in
save_base
  527. result = manager._insert(values,
return_id=update_pk, using=using)
File "C:\Python26\lib\site-packages\django\db\models\manager.py" in
_insert
  195. return insert_query(self.model, values, **kwargs)
File "C:\Python26\lib\site-packages\django\db\models\query.py" in
insert_query
  1480. return
query.get_compiler(using=using).execute_sql(return_id)
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py"
in execute_sql
  783. cursor = super(SQLInsertCompiler,
self).execute_sql(None)
File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py"
in execute_sql
  727. cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends\util.py" in
execute
  15. return self.cursor.execute(sql, params)
File "C:\Python26\lib\site-packages\django\db\backends
\sqlite3\base.py" in execute
  200. return 

help setting 'apps' folder... path issue

2010-09-22 Thread justin jools
I am trying to run my apps from 'apps' folder
and have 'apps.registration' installed apps/settings.py

but the admin.py is having some problem with the path and I get error
in admin:

ImportError at /admin

No module named registration.models

Request Method: GET
Request URL: http://devhead.alwaysdata.net/admin
Django Version: 1.2
Exception Type: ImportError
Exception Value:

No module named registration.models

Exception Location: /home/devhead/www/mysite/apps/registration/
admin.py in , line 3

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: help setting 'apps' folder Error: No module named registration

2010-09-22 Thread justin jools
add to settings.py:
import os
import sys
PROJECT_ROOT = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(PROJECT_ROOT, "apps"))

full article:

http://codespatter.com/2009/04/10/how-to-add-locations-to-python-path-for-reusable-django-apps/

On Sep 21, 10:14 pm, justin jools <justinjo...@gmail.com> wrote:
> I have setup 'apps' folder with __init__.py inside and
> 'registration' app inside 'apps'
>
> I then refer to it with:
> 'apps.registration' in installed_apps/settings.py
>
> When I run syncdb it gives error:
>
> Error: No module named registration

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



help setting 'apps' folder Error: No module named registration

2010-09-21 Thread justin jools
I have setup 'apps' folder with __init__.py inside and
'registration' app inside 'apps'

I then refer to it with:
'apps.registration' in installed_apps/settings.py

When I run syncdb it gives error:

Error: No module named registration

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: how to replace "Congratulations on your first Django-powered page." with my home page

2010-09-16 Thread Justin Myers
It already tells you why it's showing that page. You need to add some
entries to urls.py, at the very least. The tutorial Sithembewena
linked you to is a good start.
-Justin

On Sep 16, 12:25 am, perfecthills <perfecthi...@yahoo.com> wrote:
> Have a website build on django, i desire to transfer the website to a
> new domain, i already created the application and even website at
> webfaction, i have even copied the entire code of the previous site to
> the ftp of the new website iwant. well being new, all i get is
>
> It worked!
> Congratulations on your first Django-powered page.
>
> Of course, you haven't actually done any work yet. Here's what to do
> next:
>
>     * If you plan to use a database, edit the DATABASES setting in
> myproject/settings.py.
>     * Start your first app by running python myproject/manage.py
> startapp [appname].
>
> You're seeing this message because you have DEBUG = True in your
> Django settings file and you haven't configured any URLs. Get to work!
>
> can someone suggest what else i need to do.
> thanx

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Template library account_tags not found | 'account_tags' is not a valid tag library

2010-09-12 Thread justin jools
getting this error trying to load templatetag in my  account_tags
template:

{% load account_tags %}

get this error: (detail at btootm)
Template library account_tags not found |  'account_tags' is not a
valid tag library

tried at bash:
from django.contrib.admin.templatetags import account_tags

get error:
 ImportError: Settings cannot be imported, because environment
variable DJANGO_SETTINGS_MODULE is undefined

so tried (as suggested on one site):
set DJANGO_SETTINGS_MODULE=mysite.settings

but didnt make any difference

Does anyone have any ideas? Have been bashing my head with this for a
couple of hours

Many Thanks.

---
TemplateSyntaxError at /friends/invite/

'account_tags' is not a valid tag library: Template library
account_tags not found, tried
django.templatetags.account_tags,django.contrib.admin.templatetags.account_tags,django.contrib.humanize.templatetags.account_tags,tagging.templatetags.account_tags,timezones.templatetags.account_tags

Request Method: GET
Request URL:http://127.0.0.1:8000/friends/invite/
Django Version: 1.3 pre-alpha
Exception Type: TemplateSyntaxError
Exception Value:

'account_tags' is not a valid tag library: Template library
account_tags not found, tried
django.templatetags.account_tags,django.contrib.admin.templatetags.account_tags,django.contrib.humanize.templatetags.account_tags,tagging.templatetags.account_tags,timezones.templatetags.account_tags

Exception Location: C:\Python26\lib\site-packages\django\template
\defaulttags.py in load, line 921
Python Executable:  C:\Python26\python.exe
Python Version: 2.6.4
Python Path:['C:\\django\\swift', 'C:\\Python26\\lib\\site-packages\
\html5lib-0.90-py2.6.egg', 'C:\\Python26...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Integrating User Profile with Auth

2010-09-12 Thread Justin Myers
Another idea would be to connect to User's post-save signal. You can
set it up to check whether the User instance being saved is just being
created, and if so, you can create its UserProfile instance at the
same time. That'd make it so all future users have profiles as soon as
they're created; once you create UserProfile instances for each of
your existing users, you could probably avoid the check altogether.

Example:
from django.db.models.signals import post_save
from django.contrib.auth.models import User

def create_profile(sender, **kwargs):
if 'created' in kwargs and 'instance' in kwargs:
if kwargs['created']:
profile = UserProfile(user=kwargs['instance'])
profile.save()
post_save.connect(create_profile, sender=User)

HTH,
Justin

On Sep 11, 8:45 pm, darren <backdoc...@gmail.com> wrote:
> I think that my main problem was that I was expecting the save to the model
> form to actually create the profile.
>
> Here's what I ended up with in my view.
>
>  86 @login_required
>  87 def createProfile(request):
>  88     UserProfile.objects.get_or_create(user=request.user)[0]
>  89     if request.method == 'POST':
>  90         form = UserProfileForm(request.POST,
> instance=request.user.get_profile())
>  91         if form.is_valid():
>  92             form.save()
>  93             return HttpResponseRedirect("/")
>  94         else:
>  95             return render_to_response('fav/createProfile.tpl', { 'form'
> : form  }, RequestContext(request) )
>  96     else:
>  97         form = UserProfileForm(instance=request.user.get_profile())
>  98     return render_to_response('fav/createProfile.tpl', { 'form' : form}, 
> RequestContext(request))
>
>  99
>
> On Sat, Sep 11, 2010 at 12:37 AM, Shawn Milochik <sh...@milochik.com> wrote:
> > I think you just may be missing a call to get_profile() in this view.
> > You can just do that and do a try block with an except block for
> > DoesNotExist. That will let you know the situation you're in, whether
> > the profile already existed or not.
>
> > Also, unless I'm misreading something you're trying to pass a User
> > instance as the instance for a user profile, which will not work. If
> > anything, you should be doing a .get() on the user profile where user
> > = request.user, but that doesn't matter anyway because get_profile()
> > does the same thing and is the correct way to do this.
>
> > Shawn
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



have gdata-2.0.11 installed | cant find gdata.contacts.service | error: no attribute 'GDATA_NAMESPACE'

2010-09-12 Thread justin jools
I am installing django-friends and am getting error from importer.py:

(full file at: 
http://github.com/jtauber/django-friends/blob/master/friends/importer.py)

cannot not import this, yet I have gdata-2.0.11 on my python path,
with contacts.service inside
import gdata.contacts.service

is causing this error

Tried contacts in module friends_app.views. Error was: 'module' object
has no attribute 'GDATA_NAMESPACE'

Any ideas why it cant run or find gdata.contacts.service?

Many Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-simple-freinds: template tags and Friendship request

2010-09-10 Thread justin jools
Hi Preston thanks for your response but still having problem with
this:

views.py (full list below) passes:

extra_context['friendship_requests'] = {'incoming':
incoming_requests,
'outgoing':
outgoing_requests}

I have tried looping through this to extract from_user and to_user as
seperate variables but it doesnt work:

  test for friendship_requests
  {% for friendship_requests in friendsrequest_list %}
 {{ friendship_requests.incoming.from_user}}
  {% endfor %}
  

although not producing an error it write out no data...

Could you suggest how to extract from_user and to_user variables.


My other question is regarding the templatetags (full listing add
bottom)

I think it works like this:
{% load friends_tags %}

{% add_to_friends target_user %}

it then redirects to _add_to.htmtl template, I'm not entirely sure
what I should have in this template: something like 'User1 was added
to your friends'

Thanks for your help

views

@login_required
def friend_list(request,
username=None,
paginate_by=None,
page=None,
allow_empty=True,
template_name='friends/friends_list.html',
extra_context=None,
template_object_name='friends'):
if username:
user = get_object_or_404(User, username=username)
else:
user = request.user
friends = Friendship.objects.friends_of(user)
if extra_context is None:
extra_context = {}
incoming_requests = FriendshipRequest.objects.filter(
 to_user=request.user,
accepted=False)
outgoing_requests = FriendshipRequest.objects.filter(
   from_user=request.user,
accepted=False)
extra_context['sender_user'] = request.user
extra_context['target_user'] = user
extra_context['friendship_requests'] = {'incoming':
incoming_requests,
'outgoing':
outgoing_requests}
extra_context['user_blocks'] =
request.user.user_blocks.blocks.all()
return object_list(request,
   queryset=friends,
   paginate_by=paginate_by,
   page=page,
   allow_empty=allow_empty,
   template_name=template_name,
   extra_context=extra_context,
   template_object_name=template_object_name)

models
class FriendshipRequest(models.Model):
from_user = models.ForeignKey(User,
related_name="invitations_from")
to_user = models.ForeignKey(User, related_name="invitations_to")
message = models.CharField(max_length=200, blank=True)
created = models.DateTimeField(default=datetime.datetime.now,
   editable=False)
accepted = models.BooleanField(default=False)

class Meta:
verbose_name = _(u'friendship request')
verbose_name_plural = _(u'friendship requests')
unique_together = (('to_user', 'from_user'),)

def __unicode__(self):
return _(u'%(from_user)s wants to be friends with %
(to_user)s') % \
{'from_user': unicode(self.from_user),
 'to_user': unicode(self.to_user)}

def accept(self):
Friendship.objects.befriend(self.from_user, self.to_user)
self.accepted = True
self.save()
signals.friendship_accepted.send(sender=self)

def decline(self):
signals.friendship_declined.send(sender=self, cancelled=False)
self.delete()

def cancel(self):
signals.friendship_declined.send(sender=self, cancelled=True)
self.delete()

template tags
full version at : 
http://github.com/muhuk/django-simple-friends/blob/master/friends/templatetags/friends_tags.py

@register.tag
def add_to_friends(parser, token):
bits = token.split_contents()
tag_name, bits = bits[0], bits[1:]
if not bits:
raise template.TemplateSyntaxError(
   '%s tag requires at least one argument' %
tag_name)
elif len(bits) > 3:
raise template.TemplateSyntaxError(
'%s tag takes at most three arguments' %
tag_name)
if len(bits) == 3:
if bits[2].startswith('"') and bits[2].endswith('"'):
bits[2] = bits[2][1:-1]
else:
raise template.TemplateSyntaxError(
  'Third argument for %s tag must be a string' %
tag_name)
return AddToFriendsNode(*bits)


class AddToFriendsNode(template.Node):
def __init__(self, target_user, current_user='user',
   template_name='friends/_add_to.html'):
self.target_user = template.Variable(target_user)
self.current_user = template.Variable(current_user)
self.template_name = template_name

def render(self, context):
target_user = self.target_user.resolve(context)
current_user = 

django-simple-friends help

2010-09-10 Thread justin jools
Hi,

I am using django-simple-friends app and was hoping you would give me
some guidance.
http://github.com/muhuk/django-simple-friends

I have set up friends_list.html no problem:
 Friend List
Friends for {{ user }}
  
  {% for friends in friends_list %}
  {{ friends.username }}
  {% endfor %}
  
 and understand how to send friend request via url:
 http://127.0.0.1:8000/friends/add/jim
 but I am having problems listing friend requests:
 {{ friendship_requests.incoming }} spits out (below) and I coudn't
work how to remove the [< >]
or access the User sending the friend request.
 []

So I figured this is wrong to do it.
So I tried templatetags:

{% load friends_tags %}
{% add_to_friends 3 %}

which works, and redirects to _add_to.html
which I'm guessing should have a message like You have made a friend
request to User _
don't know how to get User being sent to.

 Does anyone have a working example or can you help me clear up these
issues. Thanks for your help

Sincerely,
JusinJools

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django simple friends help

2010-09-10 Thread justin jools
Hi Muhuk,

I am using django-simple-friends app and I was hoping someone would
give me some guidance.
http://github.com/muhuk/django-simple-friends

I have set up friends_list.html no problem:
 Friend List
Friends for {{ user }}
  
  {% for friends in friends_list %}
  {{ friends.username }}
  {% endfor %}
  
 and understand how to send friend request via url:
 http://127.0.0.1:8000/friends/add/jim
 but I am having problems listing friend requests:
 {{ friendship_requests.incoming }} spits out (below) and I coudn't
work how to remove the [< >]
or access the User sending the friend request.
 []

So I figured this is wrong to do it.
So I tried templatetags:

{% load friends_tags %}
{% add_to_friends 3 %}

which works, and redirects to _add_to.html
which I'm guessing should have a message like You have made a friend
request to User _
don't know how to get User being sent to.

Does anyone have a working example or can you help me clear up these
issues. Thanks for your help

Sincerely,
JusinJools

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-simple-freinds: template tags and Friendship request

2010-09-09 Thread justin jools
Hi Muhuk,

I am using django-simple-friends app, much easier to setup than django-
friends.
but need a little help and was hoping for some guidance.

I have set up friends_list.html no problem:
 Friend List
Friends for {{ user }}
  
  {% for friends in friends_list %}
  {{ friends.username }}
  {% endfor %}
  

 and understand how to send friend request via url:

 http://127.0.0.1:8000/friends/add/jim

 but I am having problems listing friend requests:

 {{ friendship_requests.incoming }} spits out (below) and I coudn't
work how to remove the [< >]

or access the User sending the friend request.

 []


So I figured this is wrong to do it.
So I tried templatetags:

{% load friends_tags %}
{% add_to_friends 3 %}

which works, and redirects to _add_to.html
which I'm guessing should have a message like You have made a friend
request to User _
don't know how to get User being sent to.
Do you have a working example or can you help me clear up these
issues. Thanks for your help

Sincerely,
JusinJools

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Anyone used django-simple-friends?

2010-09-08 Thread justin jools
Have setup django-simple-friends,

adn can pass url to add/block/delete friends easily:

http://127.0.0.1:8000/friends/add/jim/
http://127.0.0.1:8000/friends/block/jim/

http://127.0.0.1:8000/friends/list/admin/

I have the friend list template setup but don't know what variables to
pick up from views

@login_required
def friend_list(request,
username=None,
paginate_by=None,
page=None,
allow_empty=True,
template_name='friends/friends_list.html',
extra_context=None,
template_object_name='friends'):
if username:
user = get_object_or_404(User, username=username)
else:
user = request.user
friends = Friendship.objects.friends_of(user)
if extra_context is None:
extra_context = {}
incoming_requests = FriendshipRequest.objects.filter(
 to_user=request.user,
accepted=False)
outgoing_requests = FriendshipRequest.objects.filter(
   from_user=request.user,
accepted=False)
extra_context['target_user'] = user
extra_context['friendship_requests'] = {'incoming':
incoming_requests,
'outgoing':
outgoing_requests}
extra_context['user_blocks'] =
request.user.user_blocks.blocks.all()
return object_list(request,
   queryset=friends,
   paginate_by=paginate_by,
   page=page,
   allow_empty=allow_empty,
   template_name=template_name,
   extra_context=extra_context,
   template_object_name=template_object_name):

full app/views:
http://github.com/muhuk/django-simple-friends/blob/master/friends/views.py

Have tried:

  
  {% for myfriend in friends_list %}
 {{ myfriend.friends.username }}
  {% endfor %}
  


also how to setup friends tags:
http://github.com/muhuk/django-simple-friends/blob/master/friends/templatetags/friends_tags.py

Any help gretaly appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django-friends help

2010-09-07 Thread justin jools
Canyone with experience of django-friends give some setup guidelines.
I have read the docs but can't follow it easily, they are a bit sparse
for myself as beg-internediate level user.

I have installed: dajngo apps: registration, profiles, accounts,
messages, notifications and friends.

I'm having understanding how to connect the notice types to friends
and setup views and templates.

Thanks for your help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-friends | setup views.py with templates

2010-09-06 Thread justin jools
Hi I have setup jtauber notification and friends apps but now I am
stuck as to how to add views/urls to produce add friends/friends
accept/friends list etc.

please help me through the process
thx

On 6 Sep, 18:24, justin jools <justinjo...@gmail.com> wrote:
> trying to setup simple social network
> have installed: registration, profiles, accoutns, messages
>
> but am stuck as how to setup/link the views.py to templates/
> notification. I guess this is what is needed to be done.
>
> Any help much appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-friends | setup views.py with templates

2010-09-06 Thread justin jools
trying to setup simple social network
have installed: registration, profiles, accoutns, messages

but am stuck as how to setup/link the views.py to templates/
notification. I guess this is what is needed to be done.

Any help much appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django template : For Loop

2010-09-05 Thread Justin Myers
What error message is it giving you?

I'd assume it's a problem with the objects you're passing it, since
zip is a built-in Python function: 
http://docs.python.org/library/functions.html#zip

On Sep 5, 11:29 am, Jagdeep Singh Malhi 
wrote:
> > If these objects are lists, say list1 and list2, in your view just
> > create a single object made up of pairs of elements from the original lists:
>
> >    values = zip(list1, list2)
>
> > Then you can pass that item to your template and iterate over it.
>
> I tried this, its not working.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django model filter

2010-09-03 Thread Justin
Well, I'm glad it works. Please post, if you want to, a cleaner
solution if you find it!

-Justin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: fetching values from model

2010-09-02 Thread Justin Myers
In theory, if the view passed that function to the template (or if it
were available as a method on something else that was passed to the
template), I suppose you could. That said, you wouldn't be able to
pass it any arguments.

Once again, the template is _not_ designed for programming logic. It's
_only_ designed for presentation. For the most part, if you want to
call a function, call it in the view.
-Justin

On Sep 1, 11:02 pm, Pradnya <pradnya.pa...@gmail.com> wrote:
> Hey thanks,
> Is there anyway I can call a function in HTML template?
>
> On Sep 1, 6:23 pm, Steve Holden <holden...@gmail.com> wrote:
>
> > On 9/1/2010 9:13 AM, Pradnya wrote:>> ok. Is there any way I can load the 
> > model inside HTML template?
> > >> What is {% load  %} tag all about?
>
> > The {% load %} tag is for loading custom tags. Nothing to do with
> > accessing the database.
>
> > Why do you find it desirable to load records in the template?  What's
> > wrong with doing it in the view, which is what everyone else does and
> > how Django is intended to be used? See Jonas' remarks below.
>
> > regards
> >  Steve
>
> > >> On Sep 1, 6:02 pm, Jonas Geiregat <jo...@geiregat.org> wrote:
> > >>>> You don't write Python code inside your template file. That's
> > >>>> one of the basic django template rules. You can pass values
> > >>>> from your views to your template and show them there. Or
> > >>>> generate the HTML in your view and show it from there, which
> > >>>> isn't something I could advise if you're creating a larger
> > >>>> application.
>
> > >>>> Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> > >>>>>> Hello,
>
> > >>>>>> Is it possible to fetch a particular record from model
> > >>>>>> using school.object.get(id = 1) inside html template.
>
> > >>>>>> Please suggest.
>
> > >>>>>> Thanks Pradnya
>
> > >>>>>> -- You received this message because you are subscribed to
> > >>>>>> the Google Groups "Django users" group. To post to this
> > >>>>>> group, send email to django-us...@googlegroups.com. To
> > >>>>>> unsubscribe from this group, send email to
> > >>>>>> django-users+unsubscr...@googlegroups.com. For more
> > >>>>>> options, visit this group
> > >>>>>> athttp://groups.google.com/group/django-users?hl=en.
>
> > >>>> Met vriendelijke groeten,
>
> > >>>> Jonas Geiregat jo...@geiregat.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: fetching values from model

2010-09-01 Thread Justin Myers
The only way to access a model from within a template is if the view
specifically passed it via the template's context. Even then, you
wouldn't be able to do much passing the model _class_ this way; you
should be passing specific model _instances_. As the design
philosophies doc says, "We see a template system as a tool that
controls presentation and presentation-related logic – and that’s it."
http://docs.djangoproject.com/en/dev/misc/design-philosophies/#template-system

{% load %} is completely unrelated. It's used to load custom template
tags and filters: 
http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/

-Justin

On Sep 1, 8:12 am, Pradnya <pradnya.pa...@gmail.com> wrote:
> ok. Is there anyway I can load model inside HTML template? or
> basically what is {% load  %} is used for ?
>
> On Sep 1, 6:02 pm, Jonas Geiregat <jo...@geiregat.org> wrote:
>
> > You don't write Python code inside your template file. That's one of the 
> > basic django template rules.
> > You can pass values from your views to your template and show them there.
> > Or generate the HTML in your view and show it from there, which isn't 
> > something I could advise if you're creating a larger application.
>
> > Op 1-sep-2010, om 14:53 heeft Pradnya het volgende geschreven:
>
> > > Hello,
>
> > > Is it possible to fetch a particular record from model using
> > > school.object.get(id = 1) inside html template.
>
> > > Please suggest.
>
> > > Thanks
> > > Pradnya
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > Met vriendelijke groeten,
>
> > Jonas Geiregat
> > jo...@geiregat.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django GeoIP

2010-07-18 Thread Justin Myers
I did a little bit of experimenting with pygeoip a few months ago, and
it didn't seem to be _much_ slower. I wasn't doing a huge number of
requests or anything, though. Depending on your application, it's
definitely worth looking into.

On Jul 17, 6:49 pm, haibin <cai.hai...@gmail.com> wrote:
> Thanks All,
>
> Its now clear to me. For sharing purpose, maybe I'll go for pygeoip?
> Since I really only need the GeoIP only. Much simpler, though could be
> much slower?
>
> On Jul 18, 12:20 am, Justin Myers <masterb...@gmail.com> wrote:
>
> > Yes, there are dependencies for GeoIP. They're listed in the docs for
> > GeoIP (http://docs.djangoproject.com/en/1.2/ref/contrib/gis/geoip/),
> > and the docs' list of GeoDjango's requirements in general (http://
> > docs.djangoproject.com/en/1.2/ref/contrib/gis/install/#requirements)
> > is also useful.
>
> > HTH,
> > Justin
>
> > On Jul 17, 12:58 am, haibin <cai.hai...@gmail.com> wrote:
>
> > > hi,
>
> > > I am trying to use GeoIP part of GeoDjango. I importing it by from
> > > django.contrib.gis.utils import GeoIP but getting import error. Do I
> > > have to install someting or do the whole installation process for
> > > GeoDjango? Or what is the minimum requirements just for GeoIP
>
> > > Thanks,
> > > James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django GeoIP

2010-07-17 Thread Justin Myers
Yes, there are dependencies for GeoIP. They're listed in the docs for
GeoIP (http://docs.djangoproject.com/en/1.2/ref/contrib/gis/geoip/),
and the docs' list of GeoDjango's requirements in general (http://
docs.djangoproject.com/en/1.2/ref/contrib/gis/install/#requirements)
is also useful.

HTH,
Justin

On Jul 17, 12:58 am, haibin <cai.hai...@gmail.com> wrote:
> hi,
>
> I am trying to use GeoIP part of GeoDjango. I importing it by from
> django.contrib.gis.utils import GeoIP but getting import error. Do I
> have to install someting or do the whole installation process for
> GeoDjango? Or what is the minimum requirements just for GeoIP
>
> Thanks,
> James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-17 Thread Justin Myers
When is that code running? If it's in the head element and not
checking whether the document's finished yet, it might be executing
before the anchor you're targeting is ready. Consider either using
this, for something using jQuery:

$(document).ready(function() {
window.location = window.location + '#whatever';
});

or just put that one line (with a semicolon at the end, since it's
missing one) in a 

Re: Best way to get data into a HTML table?

2010-07-17 Thread Justin Myers
Each model has a meta attribute with a list of fields on it; for a
Photo model, for example, you can use Photo._meta.fields.

This means you could do something (at least in the shell) like:

>>> fields = Photo._meta.fields
>>> photo = Photo.objects.latest()
>>> for field in fields:
... print '%s: %s' % (field.name,
photo.__getattribute__(field.name))

and get a list of all of photo's field names and values. I'm not sure
how best to do this in a template yet, but it shouldn't be that hard
to figure out.

HTH,
Justin

On Jul 17, 4:11 am, Kenneth Gonsalves <law...@au-kbc.org> wrote:
> On Saturday 17 July 2010 12:30:19 david wrote:
>
> >   Just learning about Django, and I would like to know what the best
> > way to generate a table from my data, similar to what the "admin" app
> > does. I attempted to dig into the source of the admin app, but I was
> > unable to achieve much.
>
> > I don't want to create a template that has for loops that list all of
> > my data model's fields, instead, i want it to somehow generate all of
> > the public fields in my data model.
>
> best way is to create a template that has for loops that list all of your data
> model's fields - that is what django is for.
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: install django-mingus blog / http://djangoadvent.com/1.2/everything-i-hate-about-mingus/ pls help

2010-07-17 Thread justin jools
Trying to install django-mingus (see bottom, not easy at all!)
When installing  * 6 pip install -r stable-requirements.txt

ironed out 1 error with BeautifulSoup==3.0.8.1 - see bottom (http://
github.com/montylounge/django-mingus/issues/issue/36)

now I get markdown error, tried changing markdown2.0 to eariler verion
markdown1.7 made no difference:
any ideas?

from markdown import version

  File "markdown/__init__.py", line 173, in ?

etree = etree_loader.importETree()

  File "markdown/etree_loader.py", line 21, in importETree

message(CRITICAL, "Failed to import ElementTree")

  File "markdown/__init__.py", line 112, in message

raise MarkdownException, text

markdown.MarkdownException: Failed to import ElementTree

-

http://djangoadvent.com/1.2/everything-i-hate-about-mingus/

1. mkvirtualenv myblog --no-site-packages
2. workon myblog
3. cdvirtualenv
4. git clone git://github.com/montylounge/django-mingus.git
5. cd django-mingus/mingus
6. pip install -r stable-requirements.txt
7. cp local_settings.py.template local_settings.py
8. ./manage.py syncdb
9. ./manage.py loaddata test_data.json
10. ./manage.py runserver

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



  1   2   3   4   >