Re: short_description not working

2017-02-19 Thread Scott Carpenter
What does your model look like?

On Saturday, February 18, 2017 at 8:27:17 AM UTC-6, Qikai Gu wrote:
>
> Hi folks,
>
> I'm following the first django app tutorial (polls) and I'm stuck at part 
> 7 
> :
>  
> the `short_description` doesn't work.
>
> The short_description I have provided 'Published recently?' in models.py 
> did not reflect on admin app (/admin/polls/question/) as shown in tutorial 
> (need to show 'PUBLISHED RECENTLY?', but still shown "WAS PUBLISHED 
> RECENTLY")?! There is no any error shown.
>
> Does I missed something or behaviors of short_description is somehow 
> changed? 
> BTW: Reseting application and model did not help. 
>
> I'm using Django 1.10.5 with Python 3.5.2 in Ubuntu 16.04. 
>
> Thank You in advance.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/934979c4-548d-45b3-abb1-41b70dd92292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django channels in the shell

2017-02-19 Thread chris rose
I'm trying to implement a custom management command into my app.

its purpose would be to check the database for a poll which fits time 
parameters and update clients via channels.

I want to get a list of the clients in a group, then decide whether or not 
to send them new information based on their session data

I have been exploring this in the shell and im wondering why my client 
doesn't receive a message when i use the following code:

from django.conf import settings
from django.utils.module_loading import import_string

config = getattr(settings, "CHANNEL_LAYERS", {})
backend_class = import_string(config['default']['BACKEND'])
channel_layer = backend_class(config['default'].get("CONFIG", {}))

channel = channel_layer.group_channels('poll')[0]
channel_layer.send(channel, {"text": "hello world!"})


-- 
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/643c74f3-6703-4fc4-bf1e-4fa2c327ef1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Anyone know howto solve this: Error loading either pysqlite2 or sqlite3 module

2017-02-19 Thread Fernando Ramirez Dominguez
Hello, everybody:

I am a newbie in Django and I recently installed Python 3.6 and Django 
1.110.5, but  when try execute the server show me:

{code}

Traceback (most recent call last):

  File 
"/root/myDjangoProject/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py",
 
line 34, in 

from pysqlite2 import dbapi2 as Database

ModuleNotFoundError: No module named 'pysqlite2'

{code}


My version CentOS is 6.8, python 3.6 and Django 1.10.5


Thanks a lot for your time

-- 
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/7d94a98f-1b82-4244-96a0-faf0cf00721e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


any idea for get_absolute_url in m2m categories

2017-02-19 Thread carlos
Hi, any idea how to construct my get_absolute_url (
127.0.0.1:8000/category-slug/id-slug-post)
for example i have my models like this
class Category(...):
name = CharField()
slug = SlugField(.)

class MyModel(modesl.Model):
post = models.CharField()
slug = models.SlugField(.)
categories = models.ManyToMany(Category)

   def get_absolute_url(self):
   return "/%s/%s-%s/" % (self.categories.slug, self.id, self.slug)

  #error 'ManyRelatedManager' object has no attribute 'slug'
  in self.categories.slug


i would like this url in my page
127.0.0.1:8000/category-slug/id-slug-post

example
http://mydomain.com/food-green/120-one-hundry-food-green
  domain.com / category slug   / pk - (dash) post slug

the problems is for my get_absolute_url  see, one post have multiple
category
the error is:
'ManyRelatedManager' object has no attribute 'slug'

what is the best way to do this?

any idea?

Cheers

-- 
att.
Carlos Rocha

-- 
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/CAM-7rO0wbik3zq5Tj_Fc9dhQNASnLd%2Bx5mA4Xp%3DAzkKyPS%2BQtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: any idea for get_absolute_url in m2m categories

2017-02-19 Thread Mike Dewhirst

On 20/02/2017 4:00 PM, carlos wrote:
Hi, any idea how to construct my get_absolute_url 
(127.0.0.1:8000/category-slug/id-slug-post 
)

for example i have my models like this
class Category(...):
name = CharField()
slug = SlugField(.)

class MyModel(modesl.Model):
post = models.CharField()
slug = models.SlugField(.)
categories = models.ManyToMany(Category)

   def get_absolute_url(self):
   return "/%s/%s-%s/" % (self.categories.slug, self.id 
, self.slug)


  #error 'ManyRelatedManager' object has no attribute 'slug'
  in self.categories.slug


https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField

https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField.through

The "through" table doesn't need a coded Django model if it is only used 
to relate the two different tables in the m2m relationship. However, if 
you want to include other data - such as a slug - then you need to code 
it explicitly.


The "through" table will already exist in your database so choose the 
same name for the model as you see there. It will only have two foreign 
key fields, one to each of the related tables after which it is named.


Once you have a model with the two FKs and your slug, 
makemigrations/migrate will adjust it to include the slug.






i would like this url in my page
127.0.0.1:8000/category-slug/id-slug-post 



example
http://mydomain.com/food-green/120-one-hundry-food-green
domain.com  / category slug   / pk - (dash) post slug

the problems is for my get_absolute_url  see, one post have multiple 
category

the error is:
'ManyRelatedManager' object has no attribute 'slug'

what is the best way to do this?

any idea?

Cheers

--
att.
Carlos Rocha
--
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/CAM-7rO0wbik3zq5Tj_Fc9dhQNASnLd%2Bx5mA4Xp%3DAzkKyPS%2BQtg%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/3583eb1a-6b7c-29bc-d670-5245d7813cac%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.