Re: empty filter fields displaying entire queryset

2015-11-11 Thread James Schneider
On Nov 10, 2015 11:53 PM, "Daniel Sears"  wrote:
>
> I want to create a list view that searches a large dataset. But it seems
that if I use a filterset with empty defaults, then my view displays my
entire dataset.
>
> If tried creating a get_queryset method in my view that detects whether
my filter fields are empty, but this doesn't seem to have any effect:
>
> from django_filters.views import FilterView
> from .filters import ProductFilter
>
> class ProductView(FilterView):
> filterset_class = ProductFilter
> template_name = 'product_filter.html'
>
> def get_queryset(self):
> qs = super(ProductView, self).get_queryset()
> if '' not in self.request.GET.items():
> return qs.none()
> else:
> return qs
>

Yeah, you should probably remove that entire get_queryset() method and let
the FilterView do it's job.

> I looked at and experimented with STRICTNESS, but it didn't seem to have
any effect either. How can I create a view that refrains from displaying
data until I give it valid filter fields?
>
> Thanks.

I'm guessing you are using a third party package that provides FilterView,
although you didn't mention one.

Since I don't know what that inherits from, I'm going to guess ListView,
which uses a *.all() queryset by default. The easiest thing to do would be
to set your initial queryset to *.none() within your class definition,
assuming you are filtering the Product model:

class ProductView(FilterView):
queryset = Product.objects.none()
   filterset_class = ProductFilter
   template_name = 'product_filter.html'

If that doesn't work (not sure if you can chain filters on top of .none()
and get results, which is probably what FilterView is doing. I'm on my
phone so I can't check), you can also try Product.objects.filter().

-James

-- 
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/CA%2Be%2BciUd6SGDUCcvn3QsCaSRR99Cj6tsv7cU5yyWvM5Oe9%2BEhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread James Schneider
On Nov 10, 2015 9:46 AM, "Robin Fourcade"  wrote:
>
> Thanks James,
> I looked at many tutorials like:
>
>
https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-centos-7
>
https://devops.profitbricks.com/tutorials/deploy-django-with-virtualenv-on-centos-6/
>
> Neither of these are for python 3.7 or higher. :/
> i would gladly use higher version of python but I can't find any tutorial
about it. :/
>

Python 3.7 would be quite a feat considering it hasn't been invented yet.
;-P

Take a look at these and focus on the parts pertaining to Apache/httpd and
mod_wsgi.

https://github.com/crits/crits/wiki/RHEL-Supplemental-Install-Guide

https://www.webhostpython.com/billing/knowledgebase.php?action=displayarticle&id=33

https://www.google.com/search?q=centos+6+python+2.7&oq=centos+6+python+&aqs=chrome.1.69i57j0l3.8479j1j4&client=ms-android-hms-tmobile-us&sourceid=chrome-mobile&ie=UTF-8#q=centos+6+python+2.7+mod_wsgi

If you aren't comfortable compiling your own stuff, you should consider
switching to a distribution that supports 2.7 by default. RHEL/CentOS is
pretty much the last notable holdout due to their extended release schedule.

-James

-- 
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/CA%2Be%2BciW2Sa9osM%3DqLak9YU95YK8emEDqhS1iawxkCwCyPYrWAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Connecting to FirebirdSQL-Database as a second DB

2015-11-11 Thread Djangaroo
Hello everybody,

I'm having trouble connecting a second Database to my Django Project.

I would like to read Data from the Firebirdsql database, to display on my 
Website.

I have downloaded 'django-firebird'  Link 


This is the setup I am using, wicht isn't working: 

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
'zef': {
'ENGINE': 'firebird',
'NAME': os.path.join(BASE_DIR, 'Blabla.FDB'),
'USER' : 'MyDBUser',
'PASSWORD' : 'Topsecret',
'HOST' : '127.0.0.1',
'PORT' : '3050',
}   
}

and have also imported firebird and fdb:

import os, fdb, firebird

I still keep getting the following error message, when I try running my 
Server:

django.core.exceptions.ImproperlyConfigured: 'firebird' isn't an available 
database backend.
Try using django.db.backends.XXX, where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name 'BaseDatabaseOperations'

I've been stuck here for a while and would really appreciate your 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62c7b456-08e3-4054-8b75-87cdf1c47451%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Connecting to FirebirdSQL-Database as a second DB

2015-11-11 Thread Jani Tiainen

Hi,

Are you sure that django-firebird is compatible with version of Django 
you're using?


Docs seem to indicate that django-firebird supports only Django 1.6.x

On 11.11.2015 11:39, Djangaroo wrote:

Hello everybody,

I'm having trouble connecting a second Database to my Django Project.

I would like to read Data from the Firebirdsql database, to display on 
my Website.


I have downloaded 'django-firebird' Link 



This is the setup I am using, wicht isn't working:

|
DATABASES ={
'default':{
'ENGINE':'django.db.backends.sqlite3',
'NAME':os.path.join(BASE_DIR,'db.sqlite3'),
},
'zef':{
'ENGINE':'firebird',
'NAME':os.path.join(BASE_DIR,'Blabla.FDB'),
'USER':'MyDBUser',
'PASSWORD':'Topsecret',
'HOST':'127.0.0.1',
'PORT':'3050',
}
}
|

and have also imported firebird and fdb:

|
importos,fdb,firebird
|

I still keep getting the following error message, when I try running 
my Server:


django.core.exceptions.ImproperlyConfigured: 'firebird' isn't an 
available database backend.

Try using django.db.backends.XXX, where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name 'BaseDatabaseOperations'

I've been stuck here for a while and would really appreciate your 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62c7b456-08e3-4054-8b75-87cdf1c47451%40googlegroups.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 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/56430FE2.7090600%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Connecting to FirebirdSQL-Database as a second DB

2015-11-11 Thread Djangaroo
Hi,

Thanks for the quick answer! No I'm not sure if it's compatible... I'm 
using Django 1.8.2 if that helps 

I really don't know how I need to go about this. I can't find a way to 
connect my Database with the Django Project.

At the moment I'm trying to get this 
to work

On Wednesday, November 11, 2015 at 10:53:31 AM UTC+1, Jani Tiainen wrote:
>
> Hi,
>
> Are you sure that django-firebird is compatible with version of Django 
> you're using?
>
> Docs seem to indicate that django-firebird supports only Django 1.6.x
>
> On 11.11.2015 11:39, Djangaroo wrote:
>
> Hello everybody,
>
> I'm having trouble connecting a second Database to my Django Project.
>
> I would like to read Data from the Firebirdsql database, to display on my 
> Website.
>
> I have downloaded 'django-firebird'  Link 
> 
>
> This is the setup I am using, wicht isn't working: 
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
> },
> 'zef': {
> 'ENGINE': 'firebird',
> 'NAME': os.path.join(BASE_DIR, 'Blabla.FDB'),
> 'USER' : 'MyDBUser',
> 'PASSWORD' : 'Topsecret',
> 'HOST' : '127.0.0.1',
> 'PORT' : '3050',
> }   
> }
>
> and have also imported firebird and fdb:
>
> import os, fdb, firebird
>
> I still keep getting the following error message, when I try running my 
> Server:
>
> django.core.exceptions.ImproperlyConfigured: 'firebird' isn't an available 
> database backend.
> Try using django.db.backends.XXX, where XXX is one of:
> 'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
> Error was: cannot import name 'BaseDatabaseOperations'
>
> I've been stuck here for a while and would really appreciate your 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...@googlegroups.com .
> To post to this group, send email to django...@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/62c7b456-08e3-4054-8b75-87cdf1c47451%40googlegroups.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 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/ea066a7d-a517-46e9-9e23-7faae86781a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Connecting to FirebirdSQL-Database as a second DB

2015-11-11 Thread Jani Tiainen
As I said, django-firebird is compatible with Django 1.6.x and older 
releases. So it won't work with Django 1.8.2


You do have three options:

1) Fix or ask someone to fix django-firebird to support Django 1.8
2) Use Firebird database without Django ORM directly.
3) Use Django 1.6.x (not recommended since it's unsupported)



On 11.11.2015 13:03, Djangaroo wrote:

Hi,

Thanks for the quick answer! No I'm not sure if it's compatible... I'm 
using Django 1.8.2 if that helps


I really don't know how I need to go about this. I can't find a way to 
connect my Database with the Django Project.


At the moment I'm trying to get this 
to work


On Wednesday, November 11, 2015 at 10:53:31 AM UTC+1, Jani Tiainen wrote:

Hi,

Are you sure that django-firebird is compatible with version of
Django you're using?

Docs seem to indicate that django-firebird supports only Django 1.6.x

On 11.11.2015 11:39, Djangaroo wrote:

Hello everybody,

I'm having trouble connecting a second Database to my Django Project.

I would like to read Data from the Firebirdsql database, to
display on my Website.

I have downloaded 'django-firebird' Link


This is the setup I am using, wicht isn't working:

|
DATABASES ={
'default':{
'ENGINE':'django.db.backends.sqlite3',
'NAME':os.path.join(BASE_DIR,'db.sqlite3'),
},
'zef':{
'ENGINE':'firebird',
'NAME':os.path.join(BASE_DIR,'Blabla.FDB'),
'USER':'MyDBUser',
'PASSWORD':'Topsecret',
'HOST':'127.0.0.1',
'PORT':'3050',
}
}
|

and have also imported firebird and fdb:

|
importos,fdb,firebird
|

I still keep getting the following error message, when I try
running my Server:

django.core.exceptions.ImproperlyConfigured: 'firebird' isn't an
available database backend.
Try using django.db.backends.XXX, where XXX is one of:
'base', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name 'BaseDatabaseOperations'

I've been stuck here for a while and would really appreciate your
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...@googlegroups.com .
To post to this group, send email to django...@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/62c7b456-08e3-4054-8b75-87cdf1c47451%40googlegroups.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 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/ea066a7d-a517-46e9-9e23-7faae86781a6%40googlegroups.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 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/56432133.3050803%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


HttpResponse Redirect does not work with Internet Explorer behind proxy

2015-11-11 Thread Ludwig Hinske
Dear group,

I hope you can help me get an idea about where to search for a solution to 
my problem;
The application I developed displays a login-form on the start page. When 
the user successfully
logs in, the Django view returns a HttpResponseRedirect object to the 
members area view (views
protected by the @login_required decorator).

The webpage works well an all major browser (Firefox, Chrome, Safari, IE 8 
- 11). However, if 
the Internet Explorer is located on a client computer behind a proxy (or 
using an anonymous surfing
VPN tunnel),  a "Internet Explorer cannot display this webpage". Firefox, 
Chrome, and Safari are all 
running fine behind the same proxy. Unfortunately, it is important that 
users can access the webpage
using IE behind a proxy.

Does anyone have an idea, what the problem could be or how to get rid of 
it? Since I have no clue,
where to start looking for a solution, I'll be posting "configuration on 
demand" :-)

Thanks a lot in advance to all of you,
  Ludwig

-- 
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/02f0cf3b-0fd5-499d-a070-ef61f1f6e701%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TemplateSyntaxError: 'subpackage.echo' is not a valid tag library

2015-11-11 Thread Jose Paul
   getting following error ,can someone help me to understand this 

.
compiled_result = compile_func(self, token)
  File "C:\Python27\lib\site-packages\django\template\defaulttags.py", line 
1140, in load
(taglib, e))
TemplateSyntaxError: 'subpackage.echo' is not a valid tag library: Template 
library subpackage.echo not found, tried django.templatetags.subpackage.echo

-- 
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/6ac2c274-7335-4856-af73-0142d9c84ce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I server my app in apache in subdirectory?

2015-11-11 Thread frocco

Looks like it is working now.

I tried localhost/mysite (which failed)
this works localhost/mysite/admin


On Tuesday, November 10, 2015 at 3:42:07 PM UTC-5, frocco wrote:
>
> I get a 404 error
>
> WSGIScriptAlias /mysite 
> C:/MAMP/htdocs/django/vnatracking/vnatracking/wsgi.py
>
>
>>

-- 
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/657426ff-23ad-49d2-a882-1bb702517c13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Searching for the best way to provide temporary access on resources for non-registered users with the rest-framework

2015-11-11 Thread lnzy35en
 


Hi,

 

At the moment I am trying to figure out the best way to provide non-authenticated and non-registered users temporary (read and update) access to objects.

 

The first Idea I had was storing a token = models.CharField(max_length=64,unique=True) for every instance of the model which I then create in the serializer via:

def perform_create(self, serializer):

    serializer.save(owner=self.request.user, token =str(uuid.uuid4()))

 

Giving a non-registered user this token enables him to access this resource and update it, so everything is fine. From this side, but:


	Realizing it in this way, results in the user having unlimited access (in regards to time) to that resource. I would like to limit the possible access in regards to time via TimestampSigner from the django.core.signing package by also storing a max_age per item and using that to verify the token and the age via signer.unsign(token, max_age=toke_age). Unfortunately I do not know how to integrate such a mechanic in the rest-framework in combination with the generics.RetrieveUpdateAPIView
	Maybe there are better ways to archive that goal? I could overwrite the token after the specific max_age is exceeded so that only the authenticated owner gets access to it and the non-registered user will no longer be in possession of the token for this item.


Thoughts? Hints? Solutions for the TimestampSigner approach?

Best Regards,

Mike




-- 
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/trinity-95293c08-16e6-4d7d-9690-3199d2874627-1447253049712%403capp-gmx-bs41.
For more options, visit https://groups.google.com/d/optout.


Re: How do I add permissions in admin for proxy model?

2015-11-11 Thread frocco
This is still not working.


On Tuesday, November 10, 2015 at 11:36:39 AM UTC-5, frocco wrote:
>
> Just an update.
> This is now working in django 1.8.6
>
> On Monday, November 9, 2015 at 3:31:35 PM UTC-5, frocco wrote:
>>
>> I have 
>>
>> class qry485Missing(Tracking):
>> class Meta:
>> proxy = True
>> permissions = (
>> ("qry485Missing_display", "May display information"),
>> ("qry485Missing_edit", "May edit information"),
>> )
>> verbose_name = "485 Missing"
>> verbose_name_plural = "485 Missing"
>>
>>
>> This does not show up in admin to allow users access.
>>
>> I have to grant superuser status to see it.
>>
>>
>> Thanks
>>
>>

-- 
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/47e156ee-0057-4781-ac7b-e15dc75c4804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Just starting, cannot create Password for superuser

2015-11-11 Thread Raja Weise
Hi there,
I am having difficulty while following the "Writing your First Django app, 
Part 2." Everything prior to this I believe I have done correctly, as I 
have been testing along the way just as the instructions say, however when 
creating the admin user, in cmd I cd to C:\Python27\mysite (where I have 
manage.py saved) and I input the command "python manage.py createsuperuser".
It prompts me to enter a username, i put admin, I put in my email address, 
however when it asks me to make a password I can't type in anything at all. 
It won't even let me paste a string into it. I am very new to programming 
and cannot figure out what is wrong. I've tried to run cmd as an 
administrator, but that doesn't work. Can someone please help me?
Thank you very much

-- 
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/3b3e6888-eea5-4ce3-bb4f-adf725a9ac2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Just starting, cannot create Password for superuser

2015-11-11 Thread Andreas Kuhne
Hi Raja,

What do you mean it doesn't allow you to type anything at all? It shouldn't
echo anything. The prompt doesn't move when inputing the password and
that's the way it should be. Try to add a password and the press enter. You
should then be prompted to re-enter the password. Without echoing again.

Regards,

Andréas

2015-11-11 18:34 GMT+01:00 Raja Weise :

> Hi there,
> I am having difficulty while following the "Writing your First Django app,
> Part 2." Everything prior to this I believe I have done correctly, as I
> have been testing along the way just as the instructions say, however when
> creating the admin user, in cmd I cd to C:\Python27\mysite (where I have
> manage.py saved) and I input the command "python manage.py createsuperuser".
> It prompts me to enter a username, i put admin, I put in my email address,
> however when it asks me to make a password I can't type in anything at all.
> It won't even let me paste a string into it. I am very new to programming
> and cannot figure out what is wrong. I've tried to run cmd as an
> administrator, but that doesn't work. Can someone please help me?
> Thank you very much
>
> --
> 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/3b3e6888-eea5-4ce3-bb4f-adf725a9ac2d%40googlegroups.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 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/CALXYUbkLB0m1HZHB3VDW75nt7sVNNqcKTH1F9r%2BSbVR3muf5mg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Just starting, cannot create Password for superuser

2015-11-11 Thread Avraham Serour
you are able to type the password, but it is not echoed
just type your password and press enter, if I'm I remember correctly it
will ask you to type again to confirm

On Wed, Nov 11, 2015 at 7:34 PM, Raja Weise  wrote:

> Hi there,
> I am having difficulty while following the "Writing your First Django app,
> Part 2." Everything prior to this I believe I have done correctly, as I
> have been testing along the way just as the instructions say, however when
> creating the admin user, in cmd I cd to C:\Python27\mysite (where I have
> manage.py saved) and I input the command "python manage.py createsuperuser".
> It prompts me to enter a username, i put admin, I put in my email address,
> however when it asks me to make a password I can't type in anything at all.
> It won't even let me paste a string into it. I am very new to programming
> and cannot figure out what is wrong. I've tried to run cmd as an
> administrator, but that doesn't work. Can someone please help me?
> Thank you very much
>
> --
> 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/3b3e6888-eea5-4ce3-bb4f-adf725a9ac2d%40googlegroups.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 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/CAFWa6t%2B4z58NE6zpa4ukuS5szv2%3DH%3Dr3%3D_Ou8CSPgSstOV7QSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


problema con un select

2015-11-11 Thread miguel angel lopez mendo
view

def medios(request):
medios = Medio.objects.filter()
template = 'products/Clientes.html'
print medios
return render(request, template, locals())


model-

class Medio (models.Model):
nombre_medio = models.CharField(max_length=50)

def __unicode__(self):
return  self.nombre_medio


template--
Selecciona una opcion 
 {% for medio in medios %}
{{ medios.nombre_medio }}
{% endfor %}





No se cual es el error no me muestra los medios que tengo registrados 

-- 
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/d9d6474b-6046-4abc-b097-51f7b67b6429%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I add permissions in admin for proxy model?

2015-11-11 Thread Simon Charette
Hi frocco,

This might be related to #11154 
 and #17904 
.

Did you try running the `migrate` command? It looks like it might trigger 
the creation of your custom permissions 

.

Cheers,
Simon

Le mercredi 11 novembre 2015 11:06:18 UTC-5, frocco a écrit :
>
> This is still not working.
>
>
> On Tuesday, November 10, 2015 at 11:36:39 AM UTC-5, frocco wrote:
>>
>> Just an update.
>> This is now working in django 1.8.6
>>
>> On Monday, November 9, 2015 at 3:31:35 PM UTC-5, frocco wrote:
>>>
>>> I have 
>>>
>>> class qry485Missing(Tracking):
>>> class Meta:
>>> proxy = True
>>> permissions = (
>>> ("qry485Missing_display", "May display information"),
>>> ("qry485Missing_edit", "May edit information"),
>>> )
>>> verbose_name = "485 Missing"
>>> verbose_name_plural = "485 Missing"
>>>
>>>
>>> This does not show up in admin to allow users access.
>>>
>>> I have to grant superuser status to see it.
>>>
>>>
>>> Thanks
>>>
>>>

-- 
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/7f856036-d0a2-4a83-93f2-13f6f5d169bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
As I'm not comfortable at all with this, I tried with ubuntu, wich has 
python 2.7 by default.

I follow this 
tutorial: 
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04

Everything was working well, except at the end, I've 403 error.

[Wed Nov 11 12:56:37.525607 2015] [mpm_event:notice] [pid 28089:tid 
140367682340736] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 12:56:37.635193 2015] [mpm_event:notice] [pid 28192:tid 
140578408851328] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 
configured -- resuming normal operations
[Wed Nov 11 12:56:37.635323 2015] [core:notice] [pid 28192:tid 
140578408851328] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 12:56:39.823415 2015] [core:error] [pid 28196:tid 
140578239018752] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to / denied (filesystem path '/root/pizzaclub') because 
search permissions are missing on a component of the path
[Wed Nov 11 12:56:40.046750 2015] [core:error] [pid 28196:tid 
140578228528896] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') 
because search permissions are missing on a component of the path, referer: 
http://s18710917.domainepardefaut.fr/
[Wed Nov 11 12:56:41.625131 2015] [core:error] [pid 28196:tid 
140578218039040] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to / denied (filesystem path '/root/pizzaclub') because 
search permissions are missing on a component of the path
[Wed Nov 11 12:56:41.871027 2015] [core:error] [pid 28196:tid 
140578207549184] (13)Permission denied: [client 109.10.154.52:50531] 
AH00035: access to /favicon.ico denied (filesystem path '/root/pizzaclub') 
because search permissions are missing on a component of the path, referer: 
http://s18710917.domainepardefaut.fr/

I tried this: 

chmod g+x ./*
or 
chmod +x /root/pizzaclub

But it didn't solve anything. I followed the tutorial line after line, just 
to test (no even with my own project).

Thanks again,
Robin.

Le mercredi 11 novembre 2015 10:04:44 UTC+1, James Schneider a écrit :
>
>
> On Nov 10, 2015 9:46 AM, "Robin Fourcade"  > wrote:
> >
> > Thanks James,
> > I looked at many tutorials like:
> >
> > 
> https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-centos-7
> > 
> https://devops.profitbricks.com/tutorials/deploy-django-with-virtualenv-on-centos-6/
> >
> > Neither of these are for python 3.7 or higher. :/
> > i would gladly use higher version of python but I can't find any 
> tutorial about it. :/
> >
>
> Python 3.7 would be quite a feat considering it hasn't been invented yet. 
> ;-P
>
> Take a look at these and focus on the parts pertaining to Apache/httpd and 
> mod_wsgi.
>
> https://github.com/crits/crits/wiki/RHEL-Supplemental-Install-Guide
>
>
> https://www.webhostpython.com/billing/knowledgebase.php?action=displayarticle&id=33
>
>
> https://www.google.com/search?q=centos+6+python+2.7&oq=centos+6+python+&aqs=chrome.1.69i57j0l3.8479j1j4&client=ms-android-hms-tmobile-us&sourceid=chrome-mobile&ie=UTF-8#q=centos+6+python+2.7+mod_wsgi
>
> If you aren't comfortable compiling your own stuff, you should consider 
> switching to a distribution that supports 2.7 by default. RHEL/CentOS is 
> pretty much the last notable holdout due to their extended release schedule.
>
> -James
>

-- 
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/8b768c7e-b284-4fd0-a5cd-09234f71fc88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: TemplateSyntaxError: 'subpackage.echo' is not a valid tag library

2015-11-11 Thread James Schneider
On Nov 11, 2015 4:33 AM, "Jose Paul"  wrote:
>
>getting following error ,can someone help me to understand this
>
> .
> compiled_result = compile_func(self, token)
>   File "C:\Python27\lib\site-packages\django\template\defaulttags.py",
line 1140, in load
> (taglib, e))
> TemplateSyntaxError: 'subpackage.echo' is not a valid tag library:
Template library subpackage.echo not found, tried
django.templatetags.subpackage.echo
>
> --

What does the template line look like that it's throwing that error? Do you
have something like {% subpackage.echo %} in your template?

-James

-- 
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/CA%2Be%2BciXErm0JGwXh57%2By%3Db%2BaHkAbqLWe3_0nyjkpsq8aSMWQ%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread Luis Zárate
Are you install your app as root user? (/root/pizzaclub)

The permission denied it's because apache run as www-data or http user not
as root, so if you install your app as root you probably have read/write
permission problems and a big security issue.




2015-11-11 13:01 GMT-06:00 Robin Fourcade :

> /root/pizzaclub





-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyMyhUxozKZn4BE3t%2B0pfuDgBZ5cBHr-pURqwuAvxfCJ6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problema con un select

2015-11-11 Thread Alan Ávalos Hernández
En el método del view, no estás regresando la colección de objetos tipo Medio.

Sent from my iPhone

> On Nov 11, 2015, at 12:19 PM, miguel angel lopez mendo  
> wrote:
> 
> view
> 
> def medios(request):
> medios = Medio.objects.filter()
> template = 'products/Clientes.html'
> print medios
> return render(request, template, locals())
> 
> 
> model-
> 
> class Medio (models.Model):
> nombre_medio = models.CharField(max_length=50)
> 
> def __unicode__(self):
> return  self.nombre_medio
> 
> 
> template--
> Selecciona una opcion 
>  {% for medio in medios %}
> {{ medios.nombre_medio }}
> {% endfor %}
> 
> 
> 
> 
> 
> No se cual es el error no me muestra los medios que tengo registrados 
> -- 
> 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/d9d6474b-6046-4abc-b097-51f7b67b6429%40googlegroups.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 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/03A38916-A316-4B0F-BC54-66A48257285C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Hi, 
thanks for your answer.

That's what I did. So if it's a big issue, I'll create a new user on my 
server and I'll redo the installation through this user !

Thanks,
Robin.

-- 
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/81b4dbde-9979-41ca-ac5e-c38c4e2daa30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Hi,

So I made another install with a new user (pizzaclub).

I wrote this in the default.conf:



ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /static /home/pizzaclub/pizzaclub/static

Require all granted




Require all granted



WSGIDaemonProcess pizzaclub 
python-path=/home/pizzaclub:/home/pizzaclub/pizzaclubenv/lib/python2.7/site-packages
WSGIProcessGroup pizzaclub
WSGIScriptAlias / /home/pizzaclub/pizzaclub/wsgi.py



And I still have the same issue which is the 403 error:

[Wed Nov 11 15:07:26.244727 2015] [mpm_event:notice] [pid 27193:tid 
140432722884480] AH00491: caught SIGTERM, shutting down
[Wed Nov 11 15:07:26.354982 2015] [mpm_event:notice] [pid 27289:tid 
140603486005120] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 
configured -- resuming normal operations
[Wed Nov 11 15:07:26.355107 2015] [core:notice] [pid 27289:tid 
140603486005120] AH00094: Command line: '/usr/sbin/apache2'
[Wed Nov 11 15:07:28.461063 2015] [authz_core:error] [pid 27293:tid 
140603387373312] [client 109.10.154.52:51815] AH01630: client denied by 
server configuration: /home/pizzaclub/pizzaclub/wsgi.py
[Wed Nov 11 15:07:30.563364 2015] [authz_core:error] [pid 27293:tid 
140603376875264] [client 109.10.154.52:51815] AH01630: client denied by 
server configuration: /home/pizzaclub/pizzaclub/wsgi.py


Thanks again,

Robin.

-- 
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/20b471a9-96a9-45f3-beee-055edce27880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best way to consume the own API to serve both a frontend for non API users and pure API access?

2015-11-11 Thread lnzy35en

Hi guys,

 

Following the API first mindset I created my first API with Django rest-framework. Using generic-views helps a lot and makes that a piece of cake, especially with the support of the community.

 

The challenge is now to create a nice UI for the API. Normally I would create the application with Django views and forms to realize the creation and modification of data and the Django templates in combination with the twitter bootstrap (normally I would not have an API!).

Since I want to offer people access to the API to automate things as well as to a frontend in case they do not need that, I would like to have URLs like /API/Users and /Users (non API use). To not rewrite the whole application in django, I would like to consume the API myself with the Django frontend and serve the data with the Django template language. Unfortunately I have not found out how to call the API from Django to post data from a form (PUT api calls) and to display data (GET API calls) and especially parse and transform the data to be used in the API and templates.


	Is there a way to consume the own API to not rewrite the whole part?
	Is there may be a better way?  Learning node.js or stuff like that and hardcode the parameters and urls to build a frontend for the API seems like a waste of time?


Thank you very much.
Mike


 

 



-- 
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/trinity-513c2b69-3ae2-4c88-94dc-349489ddfb74-144722649%403capp-gmx-bs64.
For more options, visit https://groups.google.com/d/optout.


Re: Just starting, cannot create Password for superuser

2015-11-11 Thread Raja Weise
Thank you so much! I didn't know that it didn't echo even **.

On Wednesday, November 11, 2015 at 12:36:02 PM UTC-5, Raja Weise wrote:
>
> Hi there,
> I am having difficulty while following the "Writing your First Django app, 
> Part 2." Everything prior to this I believe I have done correctly, as I 
> have been testing along the way just as the instructions say, however when 
> creating the admin user, in cmd I cd to C:\Python27\mysite (where I have 
> manage.py saved) and I input the command "python manage.py createsuperuser".
> It prompts me to enter a username, i put admin, I put in my email address, 
> however when it asks me to make a password I can't type in anything at all. 
> It won't even let me paste a string into it. I am very new to programming 
> and cannot figure out what is wrong. I've tried to run cmd as an 
> administrator, but that doesn't work. Can someone please help me?
> Thank you very much
>

-- 
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/1e7fe8f2-f7a8-4897-93d7-235168d5c318%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Robin Fourcade
Hi,
I'm working with the auth library.

I've imported all of these:

from django.shortcuts import render, redirect
from pizza_club_order.forms import *
from pizza_club_order.models import *
from django.contrib import auth
from datetime import timedelta, date, datetime, time

But when I'm trying to do this:

auth.models.Group.objects.get(name='test')


Here's the error I get:


Traceback (most recent call last):

  File "", line 1, in 

  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 
127, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", 
line 334, in get

self.model._meta.object_name

DoesNotExist: Group matching query does not exist.


Can someone help me ?


Thanks,

Robin.

-- 
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/c4a83bd3-b32a-49cf-9e7e-65c819d143eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django on CentOS

2015-11-11 Thread Robin Fourcade
Riiigghh,
After many many many tries, it finally worked !

Thanks again, thank you, everybody!

Robin.

-- SOLVED.

-- 
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/23292725-0cfa-4643-9d33-d37670709a84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Vijay Khemlani
It seems you don't have any groups in your database with the name "test"

On Wed, Nov 11, 2015 at 7:14 PM, Robin Fourcade 
wrote:

> Hi,
> I'm working with the auth library.
>
> I've imported all of these:
>
> from django.shortcuts import render, redirect
> from pizza_club_order.forms import *
> from pizza_club_order.models import *
> from django.contrib import auth
> from datetime import timedelta, date, datetime, time
>
> But when I'm trying to do this:
>
> auth.models.Group.objects.get(name='test')
>
>
> Here's the error I get:
>
>
> Traceback (most recent call last):
>
>   File "", line 1, in 
>
>   File
> "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line
> 127, in manager_method
>
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>
>   File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
> line 334, in get
>
> self.model._meta.object_name
>
> DoesNotExist: Group matching query does not exist.
>
>
> Can someone help me ?
>
>
> Thanks,
>
> Robin.
>
> --
> 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/c4a83bd3-b32a-49cf-9e7e-65c819d143eb%40googlegroups.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 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/CALn3ei3YCCkVKzBjrbgDWDLTyQCsy38jwge1Ar0kAp87shQ-KA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Domain Driven Development

2015-11-11 Thread Alex Newman
I almost hate to bring this up, but we are reading Eric Evan's book "Domain 
Driven Development" at my company in our technical bookclub and some 
techniques in the book seem to be hard to apply in DJango. The main one 
being the notion of aggregations:

>From  http://martinfowler.com/bliki/DDD_Aggregate.html
"Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a 
cluster of domain objects that can be treated as a single unit. An example 
may be an order and its line-items, these will be separate objects, but 
it's useful to treat the order (together with its line items) as a single 
aggregate.

An aggregate will have one of its component objects be the aggregate root. 
Any references from outside the aggregate should only go to the aggregate 
root. The root can thus ensure the integrity of the aggregate as a whole."

Can we actually enforce this in django?

-- 
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/aa759e76-0192-4103-89c7-0001ed666f26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Domain Driven Development

2015-11-11 Thread Avraham Serour
I believe you could call a queryset this thing, or this thing a queryset

On Thu, Nov 12, 2015 at 12:43 AM, Alex Newman  wrote:

> I almost hate to bring this up, but we are reading Eric Evan's book
> "Domain Driven Development" at my company in our technical bookclub and
> some techniques in the book seem to be hard to apply in DJango. The main
> one being the notion of aggregations:
>
> From  http://martinfowler.com/bliki/DDD_Aggregate.html
> "Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a
> cluster of domain objects that can be treated as a single unit. An example
> may be an order and its line-items, these will be separate objects, but
> it's useful to treat the order (together with its line items) as a single
> aggregate.
>
> An aggregate will have one of its component objects be the aggregate root.
> Any references from outside the aggregate should only go to the aggregate
> root. The root can thus ensure the integrity of the aggregate as a whole."
>
> Can we actually enforce this in django?
>
> --
> 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/aa759e76-0192-4103-89c7-0001ed666f26%40googlegroups.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 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/CAFWa6tLvndNm6AKXf7UE1622T442BYiRsGQ7LLV7g6UknxvswA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Domain Driven Development

2015-11-11 Thread Mike Dewhirst

On 12/11/2015 9:43 AM, Alex Newman wrote:
I almost hate to bring this up, but we are reading Eric Evan's book 
"Domain Driven Development" at my company in our technical bookclub 
and some techniques in the book seem to be hard to apply in DJango. 
The main one being the notion of aggregations:


From  http://martinfowler.com/bliki/DDD_Aggregate.html
"Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a 
cluster of domain objects that can be treated as a single unit. An 
example may be an order and its line-items, these will be separate 
objects, but it's useful to treat the order (together with its line 
items) as a single aggregate.


An aggregate will have one of its component objects be the aggregate 
root. Any references from outside the aggregate should only go to the 
aggregate root. The root can thus ensure the integrity of the 
aggregate as a whole."


Can we actually enforce this in django?



No. But you can write methods in the aggregate root model as an API to 
manage the child models. If you are disciplined it should work.


The main problem (I think) implementing Eric Evans aggregate is deleting 
items within the boundary.


See 
https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.on_delete


Maybe it would be possible to use a callable for the root model's 
on_delete such that the constant returned is appropriate for the 
circumstances.


It is interesting and would be very useful if you worked out how to do 
it in a way we could all benefit.


Good luck.

Mike


--
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/aa759e76-0192-4103-89c7-0001ed666f26%40googlegroups.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 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/5643E7DC.3030509%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


How to get logged username in template

2015-11-11 Thread Dariusz Mysior


I am using Django 1.8 with Python 3.4 I had no idea why my template doesn't 
show my username on template profile.html :/


profile.py


{% load staticfiles %}



{% block content %}
My profile
{{ request.user.username }}
{% endblock %}


views.py


from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.shortcuts import render_to_response
from django.http import  HttpResponseRedirect
from django.core.context_processors import csrf
from django.contrib.auth import authenticate, login


def login_view(request):

if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/profile')
else:
# Return a 'disabled account' error message
...
pass
else:
# Return an 'invalid login' error message.
pass
form = AuthenticationForm()
args = {}
args.update(csrf(request))
args['form']= AuthenticationForm()
return render_to_response('accounts/login.html', args)

def my_view(request):
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
print(request.user)
if user.is_active:
login(request, user)
return HttpResponseRedirect('/accounts/profile')
else:
# Return a 'disabled account' error message
...
else:
# Return an 'invalid login' error message.
...
def profile(request):
username = request.user.username
return render_to_response('accounts/profile.html', username)

def register_user(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/register_success')
args = {}
args.update(csrf(request))
args['form']= UserCreationForm()
return render_to_response('accounts/register_user.html', args)

def register_success(request):
return render_to_response('accounts/register_success.html')



-- 
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/88ec2289-59b6-41a3-a1d7-c41be3fc0b4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.