Re: python manage.py runserver error

2016-06-24 Thread Luis Zárate
Check running

python manage.py migrate

other thing, are you sure that you have a correct database setup?

El viernes, 24 de junio de 2016, Gary Roach 
escribió:
> Hi Saranyoo
>
> I noticed that you are using python 2.7 with django 1.9.7. I would check
the django docs to see whether the two are compatible. You may want to
switch to Python 3.5.. If you are in the manage.py directory when you fired
off runserver it should have worked.
>
> Gary R.
>
> On 06/23/2016 06:56 PM, Saranyoo Tiaakekalap wrote:
>
> Guys - I am new to django, need some advise .
> I am trying to learn how to use django from official web, while I am
running through step by step .
> Just the beginning of the first step while I try to start server I hit
into issue .
> There is no change in any python after start project .
> Appreciate all the advice .
> [root@jpetetis mysite]# python manage.py runserver
> Performing system checks...
> System check identified no issues (0 silenced).
> Unhandled exception in thread started by 
> Traceback (most recent call last):
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/utils/aut
 oreload.py", line 226, in wrapper
> fn(*args, **kwargs)
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana
 gement/commands/runserver.py", line 117, in
inner_run
> self.check_migrations()
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana
 gement/commands/runserver.py", line 163, in
check_migrations
> executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/executor.py", line 20, in __init__
> self.loader = MigrationLoader(self.connection)
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/loader.py", line 49, in __init__
> self.build_graph()
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/loader.py", line 176, in build_graph
> self.applied_migrations = recorder.applied_migrations()
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/recorder.py", line 65, in applied_migrations
> self.ensure_schema()
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat
 ions/recorder.py", line 56, in ensure_schema
> with self.connection.schema_editor() as editor:
>   File
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/backen
 ds/sqlite3/schema.py", line 25, in __enter__
> self._initial_pragma_fk = c.fetchone()[0]
> TypeError: 'NoneType' object has no attribute '__getitem__'
>
> --
> 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/CAF7bBPAP5cqVpqt824ub4kh76podidLKRZnxFrVKtHQzr4D%2BCw%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/c44a8ff3-27a7-64f9-5ee2-a80d1001c03d%40verizon.net
.
> 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%2B5VyNUvqGZGqNiGxPsrtNaRrvdxC%2BJZaqAigqvTysEMSv5yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: python manage.py runserver error

2016-06-24 Thread Gary Roach

Hi Saranyoo

I noticed that you are using python 2.7 with django 1.9.7. I would check 
the django docs to see whether the two are compatible. You may want to 
switch to Python 3.5.. If you are in the manage.py directory when you 
fired off runserver it should have worked.


Gary R.

On 06/23/2016 06:56 PM, Saranyoo Tiaakekalap wrote:

Guys - I am new to django, need some advise .
I am trying to learn how to use django from official web, while I am 
running through step by step .


Just the beginning of the first step while I try to start server I hit 
into issue .

There is no change in any python after start project .
Appreciate all the advice .

[root@jpetetis mysite]# python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
Unhandled exception in thread started by 0x2b75ba622500>

Traceback (most recent call last):
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/utils/aut 
   oreload.py", line 226, in wrapper

fn(*args, **kwargs)
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana 
   gement/commands/runserver.py", line 117, in 
inner_run

self.check_migrations()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/core/mana 
   gement/commands/runserver.py", line 163, in 
check_migrations

executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat 
   ions/executor.py", line 20, in __init__

self.loader = MigrationLoader(self.connection)
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat 
   ions/loader.py", line 49, in __init__

self.build_graph()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat 
   ions/loader.py", line 176, in build_graph

self.applied_migrations = recorder.applied_migrations()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat 
   ions/recorder.py", line 65, in 
applied_migrations

self.ensure_schema()
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/migrat 
   ions/recorder.py", line 56, in ensure_schema

with self.connection.schema_editor() as editor:
  File 
"/usr/lib/python2.7/site-packages/Django-1.9.7-py2.7.egg/django/db/backen 
   ds/sqlite3/schema.py", line 25, in __enter__

self._initial_pragma_fk = c.fetchone()[0]
TypeError: 'NoneType' object has no attribute '__getitem__'


--
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/CAF7bBPAP5cqVpqt824ub4kh76podidLKRZnxFrVKtHQzr4D%2BCw%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/c44a8ff3-27a7-64f9-5ee2-a80d1001c03d%40verizon.net.
For more options, visit https://groups.google.com/d/optout.


Re: Beginner question regarding virtualenv

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

As mentioned above, your IDE may help you set up and use virtualenvs. I use 
PyCharm and it can create the environment for you and associate that with 
your project.

-- 
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/ba9c488d-b563-4822-867d-5463869fe49b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Rest Framework Custom Viewsets.

2016-06-24 Thread Tom Christie
Good stuff - make sure to add it to the django packages grid, 
here: https://www.djangopackages.com/grids/g/django-rest-framework/

You could also create a docs pull request to add a "Third Party Packages" 
to the viewsets section, 
here: http://www.django-rest-framework.org/api-guide/viewsets/#viewsets

-- 
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/99abb4b4-b91c-4356-9bf2-1d175f5a0170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multi-table Inheritance: How to add child to parent model?

2016-06-24 Thread Davi P
I think the problem in the original post was making Restaurant a subclass 
of Place:

class Restaurant(Place):

That's why Django gave an error for the missing name and address.

With a OneToOne relation pointing from each Restaurant object to a Place 
object, there's no need to include those fields in Restaurant. So it's not 
a subclass of Place:

class Restaurant(models.Model):

(As shown in the One-to-one example. Thanks for the updated link.) 

The other alternative is to keep the subclass, and remove the 
OneToOneField. Then do:

for place in Place.objects.all(): 
  restaurant = Restaurant(**{ 
'name': place.name, 
'address': place.address, 
'serves_hot_dogs': False, 
'serves_pizza': True, 
  }) 
  restaurant.save() 

--Davi



On Wednesday, June 22, 2016 at 5:45:23 PM UTC-5, Malik Rumi wrote:
>
> This thread is obviously very old, but since it helped me find the answer, 
> I thought I would share that for the benefit of others mystified by the 
> lack of information on 
> https://docs.djangoproject.com/en/1.9/topics/db/models/#multi-table-inheritance.
>  
>
>
> It turns out that although Derek's link to the docs was way out of date 
> (the page does not exist anymore) his solution was still close to correct. 
> The full documentation can be found here: 
> https://docs.djangoproject.com/en/1.9/topics/db/examples/one_to_one/
>
>
>
> On Thursday, November 4, 2010 at 1:25:25 PM UTC-7, Nan wrote:
>>
>> I have an existing model that I want to extend using multi-table 
>> inheritance.  I need to create a child instance for each parent 
>> instance in the database, but I can't figure out how.  I've scoured 
>> google and haven't come up with anything other than Ticket #7623[1]. 
>> Here are some of the things I've tried... 
>>
>> Let's adapt the Place / Restaurant example from the docs: 
>>
>> class Place(models.Model): 
>> name = models.CharField(max_length=50) 
>> address = models.CharField(max_length=80) 
>>
>> class Restaurant(Place): 
>> place = models.OneToOneField(Place, parent_link=True, 
>> related_name='restaurant') 
>> serves_hot_dogs = models.BooleanField() 
>> serves_pizza = models.BooleanField() 
>>
>> I want to do the following, in essence: 
>>
>> for place in Place.objects.all(): 
>>   restaurant = Restaurant(**{ 
>> 'place': place, 
>> 'serves_hot_dogs': False, 
>> 'serves_pizza': True, 
>>   }) 
>>   restaurant.save() 
>>
>> Of course, doing this tries to also create a new Place belonging to 
>> the new Restaurant, and throws an error because no values have been 
>> specified for the name and address fields.  I've also tried: 
>>
>> for place in Place.objects.all(): 
>>   restaurant = Restaurant(**{ 
>> 'serves_hot_dogs': False, 
>> 'serves_pizza': True, 
>>   }) 
>>   place.restaurant = restaurant 
>>   place.save() 
>>
>> This, however, doesn't create any records in the restaurant table. 
>>
>> Any suggestions? 
>>
>> [1] http://code.djangoproject.com/ticket/7623 
>>
>

-- 
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/88794cde-f18e-48ac-af64-553e928e7aa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Rest Framework Custom Viewsets.

2016-06-24 Thread Malik Junaid


A very small library for extending the functionality of DRF ModelViewSet.
Viewsets

The first of out custom viewsets is the CustomSerializerViewSet that allows 
you to specify different serializers for different actions of a viewset.
Quickstart

Install Rest Framework Custom ViewSets:

pip install rest_framework_custom_viewsets

then extend you ViewSet class from viewsets.CustomSerializerViewSet

Example:

from drf_custom_viewsets.viewsets.CustomSerializerViewSet
from myapp.serializers import DefaltSerializer, CustomSerializer1, 
CustomSerializer2

class MyViewSet(CustomSerializerViewSet):
serializer_class = DefaultSerializer
custom_serializer_classes = {
'create':  CustomSerializer1,
'update': CustomSerializer2,
}

Inspired from

   - http://stackoverflow.com/a/22922156/1531173 
   - http://stackoverflow.com/a/22755648/1531173 

Tools used in rendering this package:

   - Cookiecutter 
   - cookiecutter-djangopackage 


-- 
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/69e372be-6260-4caf-81ce-a1ff8934959a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.