Re: Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Aaron C. de Bruyn
Another fun way to deploy it is to a dokku (or Heroku) server.

Create a git repo with a requirements.txt that includes:
sentry[postgres]
psycopg2

Create a Procfile:
web: sentry --config=sentry.conf.py start
workers: sentry --config=sentry.conf.py celery worker -B

And finally a sentry.conf.py with the appropriate settings.

'git push' and wait a few minutes.

-A



On Tue, Apr 5, 2016 at 5:36 PM, Mario Gudelj  wrote:

> Look for fabulous on GitHub. It sets up all of that on ec2.
>
>
> On Wednesday, 6 April 2016, Neto  wrote:
>
>> I need a fabric to install Sentry, Redis, and configure the server with
>> nginx template, supervisor etc.
>> I have a Amazon Instance, and I want with a command install everything.
>> I have following the docs, but I had problem with sentry-worker
>> (supervisor).
>> My server also was too slow
>>
>> Em terça-feira, 5 de abril de 2016 15:54:07 UTC-3, Neto escreveu:
>>>
>>> I need to build a server using nginx to run sentry, I needed a routine
>>> to install all the necessary packages, and configure the server.
>>> I am using Ubuntu, Nginx, 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a6b376d4-2c3d-49ae-a71d-aab60069ffde%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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHqTbjmXzRh2r91a08n7YOayoWuKWNyFqZkJ%3DvTh94sn15HtCA%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 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/CAEE%2BrGqL-6fP7ks_KAGmgKMM8S49kxxZRgeUifN3tFeEb6MJJA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for ways to improve my skills

2016-04-05 Thread Chris Seberino


On Saturday, April 2, 2016 at 5:37:22 PM UTC-5, Devrhoid Davis wrote:
>
> Hi All, 
>
> I have been working with Python for just over 3 years now and have 
> recently taken up django. I have completed both the polls app and have 
> created an address book app by following a tutorial on youtube. I am 
> looking fro ways to improve my competence with django and possibly some end 
> to end website projects. Can anyone provide me with some links as to where 
> I could find resources for improving my skills and then avenues for using 
> these skills to generate income?
>
> Try to "scratch your own itch".  In other words, do you have any websites 
you wish you owned?  Are there any friends or family that might benefit 
from a web app?
Those kinds of projects will keep you motivated because they have value to 
someone unlike that polls app.  Do a few of those and make lots of mistakes
and you'll grow in no time!

Freenode's IRC channels are great to chat with great programmers as well.

cs 

-- 
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/80188f31-a931-473a-bbac-cd842e43d17e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How use model objects in ver1.9 WITHOUT an app and get rid off "Model class doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS." error mssg?

2016-04-05 Thread Chris Seberino

>
>
> Just think of an app actually being a namespace rather than an app. 
> Django uses INSTALLED_APPS entries just like a search path added to the 
> BASE_DIR so it can find your models. 
>
>
Ah yes thanks.  That helped a lot.  I just needed to basically mention
the directory in settings.py and then all was fine.

cs 

-- 
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/e348a005-3537-43b0-b7e3-bd1a0b61d114%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Mario Gudelj
Look for fabulous on GitHub. It sets up all of that on ec2.

On Wednesday, 6 April 2016, Neto  wrote:

> I need a fabric to install Sentry, Redis, and configure the server with
> nginx template, supervisor etc.
> I have a Amazon Instance, and I want with a command install everything.
> I have following the docs, but I had problem with sentry-worker
> (supervisor).
> My server also was too slow
>
> Em terça-feira, 5 de abril de 2016 15:54:07 UTC-3, Neto escreveu:
>>
>> I need to build a server using nginx to run sentry, I needed a routine to
>> install all the necessary packages, and configure the server.
>> I am using Ubuntu, Nginx, 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a6b376d4-2c3d-49ae-a71d-aab60069ffde%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbjmXzRh2r91a08n7YOayoWuKWNyFqZkJ%3DvTh94sn15HtCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Architecture of multiple Sites

2016-04-05 Thread jorrit787
These are both interesting solutions. I will give them a try, thanks!


On Tuesday, March 22, 2016 at 2:08:27 AM UTC+1, jorr...@gmail.com wrote:
>
> I'm wondering if I understand the Sites framework correctly... I'm 
> building a forum-like project which will initially be accessible from 
> mydomain.com . The project contains several apps like posts, members, 
> ads, etc. Eventually I would like to create myseconddomain.com, which 
> would have unique posts, but share the members, ads, etc. apps and look the 
> same as the first site except for the domain name and title in the header. 
> The code will be identical to the first site. Can I achieve this with a 
> single project and several SITE_IDs, or am I correct in thinking that the 
> Sites framework is only for sharing the same database across projects, and 
> not the code files? And if there is a way to share the code files, how do 
> you get around the fact that you set SITE_ID once in settings.py?
>
> Thanks in advance for the 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/96a2bd86-2470-4bcc-9d54-f9c65fcdae9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problems with dumpdata/loaddata

2016-04-05 Thread jorrit787
I want to dump and load data for two apps that I have. Using dumpdata works 
fine:

python manage.py dumpdata members posts > data.json

or

python manage.py dumpdata members posts --format=xml > data.xml

However, when I try to load the same data back with loaddata I get the 
following errors:

With JSON:
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 353, in ex
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 345, in ex
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
348, in run_fr
self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
399, in execut
output = self.handle(*args, **options)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 6
self.loaddata(fixture_labels)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 1
self.load_label(fixture_label)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 1
for obj in objects:
  File "C:\Python27\lib\site-packages\django\core\serializers\json.py", 
line 76, in Deseri
stream_or_string = stream_or_string.decode('utf-8')
  File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: 
invalid start byte



With XML:
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 353, in execute_from_comman
utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", 
line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
348, in run_from_argv
self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 
399, in execute
output = self.handle(*args, **options)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 60, in handle
self.loaddata(fixture_labels)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 100, in loaddata
self.load_label(fixture_label)
  File 
"C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", 
line 152, in load_label
for obj in objects:
  File "C:\Python27\lib\site-packages\django\utils\six.py", line 558, in 
next
return type(self).__next__(self)
  File 
"C:\Python27\lib\site-packages\django\core\serializers\xml_serializer.py", 
line 174, in __next__
for event, node in self.event_stream:
  File "C:\Python27\lib\xml\dom\pulldom.py", line 232, in next
rc = self.getEvent()
  File "C:\Python27\lib\xml\dom\pulldom.py", line 265, in getEvent
self.parser.feed(buf)
  File "C:\Python27\lib\xml\sax\expatreader.py", line 217, in feed
self._err_handler.fatalError(exc)
  File "C:\Python27\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: :1:31: encoding specified in 
XML declaration is incorrect

What gives?

-- 
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/dc3c9375-a180-45cb-b718-f272181575be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Neto
I need a fabric to install Sentry, Redis, and configure the server with 
nginx template, supervisor etc.
I have a Amazon Instance, and I want with a command install everything.
I have following the docs, but I had problem with sentry-worker 
(supervisor).
My server also was too slow

Em terça-feira, 5 de abril de 2016 15:54:07 UTC-3, Neto escreveu:
>
> I need to build a server using nginx to run sentry, I needed a routine to 
> install all the necessary packages, and configure the server.
> I am using Ubuntu, Nginx, 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a6b376d4-2c3d-49ae-a71d-aab60069ffde%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Mike Dewhirst

On 6/04/2016 4:54 AM, Neto wrote:

I need to build a server using nginx to run sentry, I needed a routine
to install all the necessary packages, and configure the server.
I am using Ubuntu, Nginx, Django.


Have a look at Mezzanine - it comes with a fabric file to install and 
maintain Nginx, Gunicorn and 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/542ea33c-1c8f-4602-8735-ac1f1c38edaa%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57043067.7000907%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Daniel Chimeno
Hello,
Sentry is a server by itself, following the installation docs you could 
install one.
https://docs.getsentry.com/on-premise/server/


El martes, 5 de abril de 2016, 20:54:07 (UTC+2), Neto escribió:
>
> I need to build a server using nginx to run sentry, I needed a routine to 
> install all the necessary packages, and configure the server.
> I am using Ubuntu, Nginx, 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b3e3ebb1-6d84-45fa-abb0-83fa3b62af39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fabric - Someone has a fabfile to build a Sentry server?

2016-04-05 Thread Neto
I need to build a server using nginx to run sentry, I needed a routine to 
install all the necessary packages, and configure the server.
I am using Ubuntu, Nginx, 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/542ea33c-1c8f-4602-8735-ac1f1c38edaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: url redirect with kwargs no NoReverseMatch

2016-04-05 Thread Luis Zárate
reverse('yourDollData', args=(doll.id,))


El martes, 5 de abril de 2016, Luigi Mognetti 
escribió:
>
http://stackoverflow.com/questions/36411798/url-redirect-with-kwargs-no-noreversematch
>
> main-project urls.py :
> from django.conf.urls import include, url
> from django.contrib import admin
>
> urlpatterns = [
> url(r'^admin/', include(admin.site.urls)),
> url(r'', include('data.urls')),
> ]
>
>
>
>
>
> urls.py : (from the data_app)
>
> urlpatterns = [
> url(r'^doll/$', views.doll_describer),
> url(r'^yourdolldata/(?P\d+)/$', views.yourDollData),
> url(r'^connexion/$', views.connexion),
> url(r'^logout/$', views.deconnexion),
> ]
>
>
>
> views.py
> def doll_describer(request):
> # if this is a POST request we need to process the form data
> if request.method == 'POST':
> # create a form instance and populate it with data from the
request:
> form = DollForm(request.POST)
> print(form)
> # check whether it's valid:
> if form.is_valid():
> print("was valid")
> doll = form.save(commit=False)
> doll.save()
> print("DOG.ID=",doll.id)
> return HttpResponseRedirect(reverse('yourDollData',
kwargs={'id': doll.id}))
>
> else :
> print("form is not valid")
>
> # if a GET (or any other method) we'll create a blank form
> else:
> form = DollForm()
> print("wasn't valid")
>
> return render(request, 'data/doll.html', {'form':DollForm})
>
> def yourDollData(request,id):
> doll = DollData.objects.get(id=id)
> print("Doll=",doll)
> print("DOG_TYPE=",type(doll))
> return render(request, 'data/save.html', {'doll': doll})
>
>
> I can't understand why i'm getting the following error :
>
>> NoReverseMatch at /doll/
> And it concerns the
> `HttpResponseRedirect(reverse('yourDollData', kwargs={'id': doll.id}))`
> Tough, everything's fine with the `doll.id` which is printed out
correctly one line before.
> Of course when I hard access in my browser to
127.0.0.1:8000/yourdolldata/15/ it works perfectly. So it's all about this
reversing process. I guess it has something to do with my url regex not
matching what I think I'm reversing ...
> How can i get that fixed ? I know it's a common mistake but I can't see
any thing done the wrong way after I've done my internet research.
>
> --
> 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/91eb6688-9f83-4491-b871-58ad7bb65d49%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyNMCbeqpJW8XiH3hou-%3Doay07_OOkwKAFsppBZ64ZR6mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: url redirect with kwargs no NoReverseMatch

2016-04-05 Thread Kristofer Pettijohn
You need to name your URLs: 
https://docs.djangoproject.com/es/1.9/topics/http/urls/#naming-url-patterns 


urlpatterns = [ 
url(r'^doll/$', views.doll_describer), 
url(r'^yourdolldata/(?P\d+)/$', views.yourDollData, name='yourDollData' ), 
url(r'^connexion/$', views.connexion), 
url(r'^logout/$', views.deconnexion), 
] 


From: "Luigi Mognetti"  
To: "Django users"  
Sent: Tuesday, April 5, 2016 12:17:39 PM 
Subject: url redirect with kwargs no NoReverseMatch 

http://stackoverflow.com/questions/36411798/url-redirect-with-kwargs-no-noreversematch
 

main-project urls.py : 

from django . conf . urls import include , url 
from django . contrib import admin 

urlpatterns = [ 
url ( r '^admin/' , include ( admin . site . urls )), 
url ( r '' , include ( 'data.urls' )), 
] 





urls.py : (from the data_app) 


urlpatterns = [ 
url ( r '^doll/$' , views . doll_describer ), 
url ( r '^yourdolldata/(?P\d+)/$' , views . yourDollData ), 
url ( r '^connexion/$' , views . connexion ), 
url ( r '^logout/$' , views . deconnexion ), 
] 



views.py 

def doll_describer ( request ): 
# if this is a POST request we need to process the form data 
if request . method == 'POST' : 
# create a form instance and populate it with data from the request: 
form = DollForm ( request . POST ) 
print ( form ) 
# check whether it's valid: 
if form . is_valid (): 
print ( "was valid" ) 
doll = form . save ( commit = False ) 
doll . save () 
print ( "DOG.ID=" , doll . id ) 
return HttpResponseRedirect ( reverse ( 'yourDollData' , kwargs ={ 'id' : doll 
. id })) 

else : 
print ( "form is not valid" ) 

# if a GET (or any other method) we'll create a blank form 
else : 
form = DollForm () 
print ( "wasn't valid" ) 

return render ( request , 'data/doll.html' , { 'form' : DollForm }) 

def yourDollData ( request , id ): 
doll = DollData . objects . get ( id = id ) 
print ( "Doll=" , doll ) 
print ( "DOG_TYPE=" , type ( doll )) 
return render ( request , 'data/save.html' , { 'doll' : doll }) 


I can 't understand why i' m getting the following error : 

> NoReverseMatch at /doll/ 

And it concerns the 
`HttpResponseRedirect(reverse('yourDollData', kwargs={'id': doll.id}))` 

Tough, everything's fine with the `doll.id` which is printed out correctly one 
line before. 

Of course when I hard access in my browser to 127.0.0.1:8000/yourdolldata/15/ 
it works perfectly. So it's all about this reversing process. I guess it has 
something to do with my url regex not matching what I think I'm reversing ... 

How can i get that fixed ? I know it's a common mistake but I can't see any 
thing done the wrong way after I've done my internet research. 



-- 
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/91eb6688-9f83-4491-b871-58ad7bb65d49%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2080868189.9145478.1459880434624.JavaMail.zimbra%40cybernetik.net.
For more options, visit https://groups.google.com/d/optout.


url redirect with kwargs no NoReverseMatch

2016-04-05 Thread Luigi Mognetti
http://stackoverflow.com/questions/36411798/url-redirect-with-kwargs-no-noreversematch

main-project urls.py : 

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('data.urls')),
]





urls.py : (from the data_app)


urlpatterns = [
url(r'^doll/$', views.doll_describer),
url(r'^yourdolldata/(?P\d+)/$', views.yourDollData),
url(r'^connexion/$', views.connexion),
url(r'^logout/$', views.deconnexion),
]



views.py

def doll_describer(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the 
request:
form = DollForm(request.POST)
print(form)
# check whether it's valid:
if form.is_valid():
print("was valid")
doll = form.save(commit=False)
doll.save()
print("DOG.ID=",doll.id)
return HttpResponseRedirect(reverse('yourDollData', kwargs={
'id': doll.id}))

else : 
print("form is not valid")

# if a GET (or any other method) we'll create a blank form
else:
form = DollForm()
print("wasn't valid")

return render(request, 'data/doll.html', {'form':DollForm})

def yourDollData(request,id):
doll = DollData.objects.get(id=id)
print("Doll=",doll)
print("DOG_TYPE=",type(doll))
return render(request, 'data/save.html', {'doll': doll})


I can't understand why i'm getting the following error : 

*> NoReverseMatch at /doll/*

And it concerns the 
`HttpResponseRedirect(reverse('yourDollData', kwargs={'id': doll.id}))`

Tough, everything's fine with the `doll.id` which is printed out correctly 
one line before. 

Of course when I hard access in my browser to 
127.0.0.1:8000/yourdolldata/15/ it works perfectly. So it's all about this 
reversing process. I guess it has something to do with my url regex not 
matching what I think I'm reversing ... 

How can i get that fixed ? I know it's a common mistake but I can't see any 
thing done the wrong way after I've done my internet research. 

-- 
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/91eb6688-9f83-4491-b871-58ad7bb65d49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to update values in instance when have a custom .update() to update many-to-many relations in DRF writable nested serializer?

2016-04-05 Thread Manjit Kumar
http://stackoverflow.com/questions/36397357/how-to-update-values-in-instance-when-have-a-custom-update-to-update-many-to

I have three models Player, Team, and Membership, Where Player and Team 
have many-to-many relationship using Membership as intermediary model.

class Player(models.Model):
name = models.CharField(max_length=254)
rating = models.FloatField(null=True)
install_ts = models.DateTimeField(auto_now_add=True, blank=True)
update_ts = models.DateTimeField(auto_now_add=True, blank=True)

class Team(models.Model):
name = models.CharField(max_length=254)
rating = models.FloatField(null=True)
players = models.ManyToManyField(
Player,
through='Membership',
through_fields=('team', 'player'))
is_active = models.BooleanField(default=True)
install_ts = models.DateTimeField(auto_now_add=True, blank=True)
update_ts = models.DateTimeField(auto_now_add=True, blank=True)

class Membership(models.Model):
team = models.ForeignKey('Team')
player = models.ForeignKey('Player')
#date_of_joining = models.DateTimeField()
install_ts = models.DateTimeField(auto_now_add=True, blank=True)
update_ts = models.DateTimeField(auto_now_add=True, blank=True)

Now I was required to update this membership using django rest framework. I 
tried update those using Writable nested serializers 

 by 
writing a custom .update() of team serializer.

@transaction.atomicdef update(self, instance, validated_data):
'''
Cutomize the update function for the serializer to update the
related_field values.
'''

if 'memberships' in validated_data:
instance = self._update_membership(instance, validated_data)

# remove memberships key from validated_data to use update method of
# base serializer class to update model fields
validated_data.pop('memberships', None)

return super(TeamSerializer, self).update(instance, validated_data)

def _update_membership(self, instance, validated_data):
'''
Update membership data for a team.
'''
memberships = self.initial_data.get('memberships')
if isinstance(membership, list) and len(memberships) >= 1:
# make a set of incoming membership
incoming_player_ids = set()

try:
for member in memberships:
incoming_player_ids.add(member['id'])
except:
raise serializers.ValidationError(
'id is required field in memberships objects.'
)

Membership.objects.filter(
team_id=instance.id
).delete()

# add merchant member mappings
Membership.objects.bulk_create(
[
Membership(
team_id=instance.id,
player_id=player
)
for player in incoming_player_ids
]
)
return instance
else:
raise serializers.ValidationError(
'memberships is not a list of objects'
)

Now this works well for updating values in database for membership table. 
Only problem I am facing is that I am not able to update prefetched 
instance in memory, which on PATCH request to this API updates values in 
database but API response is showing outdated data.

Next GET request for the same resource gives updated data. Anyone who have 
worked with many-to-many relation in django and wrote custom update/create 
methods for writable nested serializers can help me to understand the 
possible way of solving this problem.

-- 
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/5ef51dc2-af6d-419d-87da-8afca4f69185%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with Django initial setup

2016-04-05 Thread Avraham Serour
it seems you have a problem with one of your methods, you declared it
without arguments when it should receive one (self)
it looks like it is on one of your models, please recheck your models.py


On Mon, Apr 4, 2016 at 11:31 PM, George Mathew  wrote:

> Hi,
> I am trying to learn Django.
>
> I was following the official tutorial
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>
> When I entered the command "python manage.py runserver" I got the
> following error. Please help.
>
>
> *Performing system checks...*
>
> *Unhandled exception in thread started by  check_errors..wrapper at 0x01F60BFE2488>*
> *Traceback (most recent call last):*
> *  File
> "C:\Users\George\AppData\Local\Programs\Python\Python35\lib\site-packages\django\utils\autoreload.py",
> line 226, in wrapper*
> *fn(*args, **kwargs)*
> *  File
> "C:\Users\George\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\runserver.py",
> line 116, in inner_run*
> *self.check(display_num_errors=True)*
> *  File
> "C:\Users\George\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\base.py",
> line 426, in check*
> *include_deployment_checks=include_deployment_checks,*
> *  File
> "C:\Users\George\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\checks\registry.py",
> line 75, in run_checks*
> *new_errors = check(app_configs=app_configs)*
> *  File
> "C:\Users\George\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\checks\model_checks.py",
> line 14, in check_all_models*
> *for model in apps.get_models():*
> *TypeError: get_models() missing 1 required positional argument: 'self'*
>
>
> --
> 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/5110083f-c5af-47e4-9903-f4ee8fbbf337%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tJGJ%3DY6W8yE1unkMNaAsLDcAc9oVHTy7GezQ0KU4kAshg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django + Apache Web server on Windows

2016-04-05 Thread Avraham Serour
you won't have problems until you try


On Mon, Apr 4, 2016 at 8:12 PM, asimkon  wrote:

>
>  I would like to configure Django with Apache web server on Windows using
> XAMPP or Wamp. I looked over the Web until i came across the following
> video https://www.youtube.com/watch?v=VOkXG0jL_8U. Do you think i will
> have problem following all the steps along? From python installation,
> Django, mod_wsgi apache module until mod.wsgi and of course localhost in
> Apache after building a Django project and of course an app.
>
> Regards
>
> --
> 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/8f848720-89d3-471a-9693-de6d48e35dde%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tLn-FejA5VCqNCH9HJDpN-pnpFo4356nnAW50TO%2BFL_UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.