Re: simple boy start learn python

2019-01-05 Thread Abdulrasheed Ibrahim
Djangogirls tutorial will be very helpful.

https://docs.djangoproject.com/en/2.1/intro/tutorial01/

On Sat, 5 Jan 2019, 9:51 pm omar ahmed,  wrote:

> Django documentation is very good
>
> بتاريخ ٢٠١٩/٠١/٠٥ ١٠:٤٦ م، كتب :
>
>> I know that you are exp in django, so I need you tell me the best way to
>> learn django is what ?
>>
>> --
>> 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/ee9279fe-979a-4db4-a9b3-753ea7c3cc2c%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/CAOy9vcOdgLjMa52%2BOg4%2BPVeaqnM3aQWG63Y1ouLoOwdQda_NZA%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/CAPXBATT7VeXy0RC21x5Zyks2_7E0x5EaDrDAM-GNyn4-HrovPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Login with email or phone not username

2019-01-05 Thread Achyut Pandey


Hello guys i want to allow user to register and login with their email or phone 
number instead of username . How can i do that i am extending user model with 
abstractuser.

-- 
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/A50B7F88-AAE8-4A9C-AEF9-A27649F3D643%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: simple boy start learn python

2019-01-05 Thread omar ahmed
Django documentation is very good

بتاريخ ٢٠١٩/٠١/٠٥ ١٠:٤٦ م، كتب :

> I know that you are exp in django, so I need you tell me the best way to
> learn django is what ?
>
> --
> 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/ee9279fe-979a-4db4-a9b3-753ea7c3cc2c%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/CAOy9vcOdgLjMa52%2BOg4%2BPVeaqnM3aQWG63Y1ouLoOwdQda_NZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


simple boy start learn python

2019-01-05 Thread mw5301758
I know that you are exp in django, so I need you tell me the best way to 
learn django is what ?

-- 
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/ee9279fe-979a-4db4-a9b3-753ea7c3cc2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


bulk_create method works wrong for mysql db

2019-01-05 Thread Mykola Fenyk
I wrote a small test application for the company's list of employees. 
I wrote the custom migration to create the initial data and got problem 
with *python manage.py migrate*

Traceback (most recent call last):
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/backends/mysql/base.py"
, line 71, in execute
return self.cursor.execute(query, args)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/MySQLdb/cursors.py"
, line 255, in execute
self.errorhandler(self, exc, value)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/MySQLdb/connections.py"
, line 50, in defaulterrorhandler
raise errorvalue
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/MySQLdb/cursors.py"
, line 252, in execute
res = self._query(query)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/MySQLdb/cursors.py"
, line 378, in _query
db.query(q)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/MySQLdb/connections.py"
, line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1048, "Column 'company_id' cannot be 
null")


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
  File "manage.py", line 15, in 
execute_from_command_line(sys.argv)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/__init__.py"
, line 381, in execute_from_command_line
utility.execute()
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/__init__.py"
, line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/base.py"
, line 316, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/base.py"
, line 353, in execute
output = self.handle(*args, **options)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/base.py"
, line 83, in wrapped
res = handle_func(*args, **kwargs)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/core/management/commands/migrate.py"
, line 203, in handle
fake_initial=fake_initial,
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/migrations/executor.py"
, line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, 
fake_initial=fake_initial)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/migrations/executor.py"
, line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=
fake_initial)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/migrations/executor.py"
, line 244, in apply_migration
state = migration.apply(state, schema_editor)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/migrations/migration.py"
, line 121, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, 
project_state)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/migrations/operations/special.py"
, line 190, in database_forwards
self.code(from_state.apps, schema_editor)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django_print_sql/print_sql.py"
, line 64, in wrapped
return func(*fargs, **fkwargs)
  File 
"/home/mykola/projects/company/departments/migrations/0002_initial_creation_data.py"
, line 36, in create_objects
) for index in range(1, NUMBER)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/models/manager.py"
, line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/models/query.py"
, line 465, in bulk_create
ids = self._batched_insert(objs_without_pk, fields, batch_size)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/models/query.py"
, line 1155, in _batched_insert
self._insert(item, fields=fields, using=self.db)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/models/query.py"
, line 1136, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/models/sql/compiler.py"
, line 1289, in execute_sql
cursor.execute(sql, params)
  File 
"/home/mykola/.virtualenvs/employees/lib/python3.5/site-packages/django/db/backends/utils.py"
, line 100, in execute
return super().execute(sql, params)
  File 

Re: django use models from outside script

2019-01-05 Thread PASCUAL Eric
The simplest way to do this is implementing a custom admin command, which will 
be invoked then with :
./manage.py my_awesome_command


It will take care for you of setting the Django environment (i.e. updating the 
Python path so that the apps are included in it, applying settings and making 
your apps available to the command).

Have  a look here for detail :
https://docs.djangoproject.com/en/2.1/howto/custom-management-commands/


Eric



From: django-users@googlegroups.com  on behalf 
of Samuel Muiruri 
Sent: Saturday, January 5, 2019 1:52:04 PM
To: Django users
Subject: django use models from outside script

I have an external script that I want to have access to django's models 
primarily because it's an external implementation of sockets which is simple I 
want to see if this is possible.

This is the snippet of code I added below the settings.py file based on an 
answer on stackoverflow.

#Allow Django to be used externally
from django.conf import settings
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
},
#TIME_ZONE='America/Montreal',
)

and at the start of my separate script named `path.py` I did the following 
imports

import django

import pixelart.settings

os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"pixelart.settings"
)
django.setup()

from gallery.models import ThumbnailCache, Area, Color

### Note: My django project is called pixelart with a model gallery I'm 
importing models from.

When I try to run the script I get the following error:

(pixelart) sam@sam-Lenovo-G51-35:~/code/pixelart$ python path.py
Traceback (most recent call last):
File "path.py", line 23, in 
from gallery.models import ThumbnailCache, Area, Color
File "/home/sam/code/pixelart/gallery/models.py", line 2, in 
from django.contrib.auth.models import User
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/auth/models.py",
 line 3, in 
from django.contrib.contenttypes.models import ContentType
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/contenttypes/models.py",
 line 134, in 
class ContentType(models.Model):
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/db/models/base.py",
 line 95, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType 
doesn't declare an explicit app_label and isn't in an application in 
INSTALLED_APPS.

One suggestion I've found based on [this question][1] is to add the sites to 
the installed apps and the site_id.

After trying this out and doing a migration the error remained the same.


  [1]: 
https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex

To be clear  I have an actual django model with a file called path in the main 
project directory. since I'm running them separately i.e. one one terminal 
python manage.py runserver and on another python path.py the path creates the 
sockets. And since some of the data created would best be stored in a model I 
need the path file to access the model.

--
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/d6c32914-e42f-48a3-bf59-c2835006e4bc%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/AM0P193MB0308F2FE55D3AB319B4758F98C8F0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: quête de directives

2019-01-05 Thread PASCUAL Eric
Bonjour,


pip install django


et un petit tour dans la documentation de Django ne ferait pas de mal, car ce 
point est couvert ici :

https://docs.djangoproject.com/en/2.1/intro/install/


Eric



From: django-users@googlegroups.com  on behalf 
of Moise Sacko 
Sent: Saturday, January 5, 2019 1:48:37 PM
To: Django users
Subject: quête de directives

Bonjour à tous et toute. je voudrais avoir des directives pour l'installation 
de Django. Merci d'avance


--
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/f2d4c7fc-d65c-4002-a181-9c60aa1348fc%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/AM0P193MB030838E7AB677C4CC693A7BC8C8F0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


django use models from outside script

2019-01-05 Thread Samuel Muiruri
I have an external script that I want to have access to django's models 
primarily because it's an external implementation of sockets which is 
simple I want to see if this is possible.

This is the snippet of code I added below the settings.py file based on an 
answer on stackoverflow.

#Allow Django to be used externally
from django.conf import settings
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
},
#TIME_ZONE='America/Montreal',
)

and at the start of my separate script named `path.py` I did the following 
imports

import django

import pixelart.settings

os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"pixelart.settings"
)
django.setup()

from gallery.models import ThumbnailCache, Area, Color

### Note: My django project is called pixelart with a model gallery I'm 
importing models from.

When I try to run the script I get the following error:

(pixelart) sam@sam-Lenovo-G51-35:~/code/pixelart$ python path.py
Traceback (most recent call last):
File "path.py", line 23, in 
from gallery.models import ThumbnailCache, Area, Color
File "/home/sam/code/pixelart/gallery/models.py", line 2, in 
from django.contrib.auth.models import User
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/auth/models.py",
 
line 3, in 
from django.contrib.contenttypes.models import ContentType
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/contenttypes/models.py",
 
line 134, in 
class ContentType(models.Model):
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/db/models/base.py",
 
line 95, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class 
django.contrib.contenttypes.models.ContentType doesn't declare an explicit 
app_label and isn't in an application in INSTALLED_APPS.

One suggestion I've found based on [this question][1] is to add the sites 
to the installed apps and the site_id.

After trying this out and doing a migration the error remained the same.


  [1]: 
https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex

To be clear  I have an actual django model with a file called path in the 
main project directory. since I'm running them separately i.e. one one 
terminal python manage.py runserver and on another python path.py the path 
creates the sockets. And since some of the data created would best be 
stored in a model I need the path file to access the model. 

-- 
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/d6c32914-e42f-48a3-bf59-c2835006e4bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


quête de directives

2019-01-05 Thread Moise Sacko
Bonjour à tous et toute. je voudrais avoir des directives pour 
l'installation de Django. Merci d'avance

-- 
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/f2d4c7fc-d65c-4002-a181-9c60aa1348fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Combine an otree django project with oscar django project and pass data around?

2019-01-05 Thread Alexander Rogowski
I have an oTree survey and I am working on an oscar shop. Now I want to 
combine them.

I first start the otree project (locally, otree devserver on port 8000). 
After the questions, I start a subprocess to call another server (py 
manage.py runserver, port 8080) and open another browser tab. 

Based on the answers, I would like to assign the player budget in the shop. 
How can I pass data through the projects?

from survey.models import Player  # otree models

class CatalogueView(TemplateView):
 """
 Browse all products in the catalogue
 """
 model = Player
 context_object_name = "products"



But I just get this error: 


ModuleNotFoundError: No module named 'otree'

I also put otree to INSTALLED_APPS and I tried to import otree.api.

Any ideas, how to handle this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/943608f5-7ebd-46ab-a376-6794966eadb7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.