Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Sonali Vighne

I am getting this error

raise MigrationSchemaMissing("Unable to create the django_migrations table 
(%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create 
the django_migrations table ((1064, "You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the 
right syntax to use near '(6) NOT NULL)' at line 1"))

-- 
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/2b7b7b18-77a4-4209-bb3f-e0afe48e9611%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Jason
sounds like you have some bad syntax in your models.  can't diagnose any 
further without the code.

For future reference, when you ask for help, try to give all relevant 
information in your question.  All you give here is the error, but nothing 
about the code that produces it, (the models).

-- 
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/0af70166-e58f-46f5-b025-3ef20c3cc00c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customise Session Engine to distribute session data storage

2018-08-28 Thread Jason
Actually, there's nothing stopping you from using redis for cache and 
session cache.  

SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

will use your cache to store sessions.  and if you use cached_db instead of 
cache, that data will persist in redis and survive restarts.

On Tuesday, August 28, 2018 at 1:40:38 AM UTC-4, Web Architect wrote:
>
> Hi Jason,
>
> Thanks for the response. Why not use Django's cache backend and setting 
> cache alias to be redis?
>
> Thanks. 
>
> On Monday, August 27, 2018 at 5:01:08 PM UTC+5:30, Jason wrote:
>>
>> there's an option to use redis as a session backend, which would be 
>> faster than using a regular db, even a well tuned mysql/postgres instance
>>
>> https://github.com/martinrusev/django-redis-sessions
>>
>> On Monday, August 27, 2018 at 3:52:06 AM UTC-4, Web Architect wrote:
>>>
>>> Hi,
>>>
>>> Right now we are using the Django cache_db session engine for persistent 
>>> sessions and also for some speed. Is it possible to customise this where I 
>>> can store some session data in cache and some in DB? For example, I want to 
>>> store all login sessions in DB and rest like some user specific data - 
>>> basket etc in cache .
>>>
>>> Looking forward to your support
>>>
>>> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/51a4dbf4-ad4c-45d7-91e4-3f51374a6807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customise Session Engine to distribute session data storage

2018-08-28 Thread Jason
and redis-sessions seems to be a wrapper around with more functionality, 
but the lib is a little out of date.  Got confused by the latest commit in 
master making it seem it was under maintenance but the latest release is 
over a year ago.

-- 
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/5722df99-dfae-494c-9571-6d0ff0495fce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Mohammad Aqib
make sure you have installed correct Django and MySQLclient versions. If
not try to change the versions.

or give permissions to user

grant usage on schema public to username;grant create on schema public
to username;


On Tue, Aug 28, 2018 at 1:20 PM Sonali Vighne 
wrote:

>
> I am getting this error
>
> raise MigrationSchemaMissing("Unable to create the django_migrations table
> (%s)" % exc)
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create
> the django_migrations table ((1064, "You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near '(6) NOT NULL)' at line 1"))
>
> --
> 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/2b7b7b18-77a4-4209-bb3f-e0afe48e9611%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Mohd Aqib
Software Engineer
9873141865

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


new to django

2018-08-28 Thread nonofo kokotetso
how do i deploy/run django projects after installing django and python

-- 
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/3830c5d5-b063-4af3-9371-9ac8a54744dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Check file input extension

2018-08-28 Thread René L . Hechavarría
Hi everyone, i need check file input format in forms.py, someone have any
example. Thanks in advance.

My model form:

class TestModelForm(forms.ModelForm):
class Meta:
model = TestModel
exclude = ('id')

widgets = {
'doc_1': forms.FileInput(attrs={'class': 'form-control
custom-file-input'}), }

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


attribute error

2018-08-28 Thread Imran Sharief
hi every one i am new to django am getting attribute error past from 2 days 
i got stuck in this error only i have attached the file also plz do help me 
to resolve this error

-- 
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/ccbece42-238d-411b-854d-e279b9dcb682%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trying to replace a char field with a forgein key feild

2018-08-28 Thread Codewise IO
You are going to want to create an empty migrations file and edit it to make 
your data transformations. See this article.

https://simpleisbetterthancomplex.com/tutorial/2017/09/26/how-to-create-django-data-migrations.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/986ed380-38dc-4188-ae0e-d97a9a0086b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to django

2018-08-28 Thread Manmeet Singh
Also check out this
https://tutorial.djangogirls.org/en/django_start_project/

On Tue, Aug 28, 2018 at 5:11 PM Manmeet Singh <97singh.manm...@gmail.com>
wrote:

> Check out this tutorial:
>
> https://www.digitalocean.com/community/tutorials/how-to-create-a-django-app-and-connect-it-to-a-database
>
>
> On Tue, Aug 28, 2018 at 5:05 PM nonofo kokotetso <
> nonofokokote...@gmail.com> wrote:
>
>> how do i deploy/run django projects after installing django and python
>>
>> --
>> 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/3830c5d5-b063-4af3-9371-9ac8a54744dc%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/CAPG7oKOD1xcxsMdGeDr1qA%3D44Oh6TV0TPE_uMc_6TC7nQwYEUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to django

2018-08-28 Thread Manmeet Singh
Check out this tutorial:
https://www.digitalocean.com/community/tutorials/how-to-create-a-django-app-and-connect-it-to-a-database


On Tue, Aug 28, 2018 at 5:05 PM nonofo kokotetso 
wrote:

> how do i deploy/run django projects after installing django and python
>
> --
> 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/3830c5d5-b063-4af3-9371-9ac8a54744dc%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/CAPG7oKNhTwBKWj6sYQfODW8Zm0%3DnrqXUDMzwYQdZp--Qv4NsLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: attribute error

2018-08-28 Thread Andréas Kühne
HI,

You are trying to include a view that is called views from the module home
in the app jobs.

I think what you mean is :
path('', jobs.views.home, name='home')

Try that instead.

Regards,

Andréas


Den tis 28 aug. 2018 kl 13:35 skrev Imran Sharief :

> hi every one i am new to django am getting attribute error past from 2
> days i got stuck in this error only i have attached the file also plz do
> help me to resolve this error
>
> --
> 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/ccbece42-238d-411b-854d-e279b9dcb682%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/CAK4qSCdHUeouMFu_5S3ZGLVoJ%3Df8YoWdChKUYoZWzVS%3DGa8_cA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Sonali Vighne


I will paste full error and stack trace here.

This is occurred when I am giving “python manage.py migrate” command

 

Operations to perform:

  Apply all migrations: admin, auth, contenttypes, sessions

Running migrations:

Traceback (most recent call last):

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 83, in _execute*

return self.cursor.execute(sql)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
 
line 71, in execute*

return self.cursor.execute(query, args)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 250, in execute*

self.errorhandler(self, exc, value)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
 
line 50, in defaulterrorhandler*

raise errorvalue

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 247, in execute*

res = self._query(query)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 411, in _query*

rowcount = self._do_query(q)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 374, in _do_query*

db.query(q)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
 
line 277, in query*

_mysql.connection.query(self, query)

_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL 
syntax; check the manual that corresponds to your MySQL server version for 
the right syntax to use near '(6) NOT NULL)' at line 1")

 

The above exception was the direct cause of the following exception:

 

Traceback (most recent call last):

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
 
line 55, in ensure_schema*

editor.create_model(self.Migration)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
 
line 312, in create_model*

self.execute(sql, params or None)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
 
line 133, in execute*

cursor.execute(sql, params)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 100, in execute*

return super().execute(sql, params)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 68, in execute*

return self._execute_with_wrappers(sql, params, many=False, 
executor=self._execute)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 77, in _execute_with_wrappers*

return executor(sql, params, many, context)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 85, in _execute*

return self.cursor.execute(sql, params)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\utils.py",
 
line 89, in __exit__*

raise dj_exc_value.with_traceback(traceback) from exc_value

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
 
line 83, in _execute*

return self.cursor.execute(sql)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
 
line 71, in execute*

return self.cursor.execute(query, args)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 250, in execute*

self.errorhandler(self, exc, value)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
 
line 50, in defaulterrorhandler*

raise errorvalue

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 247, in execute*

res = self._query(query)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 411, in _query*

rowcount = self._do_query(q)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
 
line 374, in _do_query*

db.query(q)

  *File 
"C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
 
line 277, in query*

_mysql.connection.query(self, query)

django.db.utils.ProgrammingE

Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Mohammad Aqib
Set mysql password.

Without password how you can access mysql.

See

DATABASES = {

*'default'*: {

*'ENGINE'*: *'django.db.backends.mysql'*,

*'NAME'*: *'hospital'*,

*'USER'*: *'root'*,

*'PASSWORD'*: *'password'*,

*'HOST'*: *'localhost'*,

*'PORT'*: *'3306'*
On Tue, 28 Aug 2018, 5:37 pm Sonali Vighne,  wrote:

>
> I will paste full error and stack trace here.
>
> This is occurred when I am giving “python manage.py migrate” command
>
>
>
> Operations to perform:
>
>   Apply all migrations: admin, auth, contenttypes, sessions
>
> Running migrations:
>
> Traceback (most recent call last):
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 83, in _execute*
>
> return self.cursor.execute(sql)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
> line 71, in execute*
>
> return self.cursor.execute(query, args)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 250, in execute*
>
> self.errorhandler(self, exc, value)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
> line 50, in defaulterrorhandler*
>
> raise errorvalue
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 247, in execute*
>
> res = self._query(query)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 411, in _query*
>
> rowcount = self._do_query(q)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 374, in _do_query*
>
> db.query(q)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
> line 277, in query*
>
> _mysql.connection.query(self, query)
>
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL
> syntax; check the manual that corresponds to your MySQL server version for
> the right syntax to use near '(6) NOT NULL)' at line 1")
>
>
>
> The above exception was the direct cause of the following exception:
>
>
>
> Traceback (most recent call last):
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
> line 55, in ensure_schema*
>
> editor.create_model(self.Migration)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
> line 312, in create_model*
>
> self.execute(sql, params or None)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
> line 133, in execute*
>
> cursor.execute(sql, params)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 100, in execute*
>
> return super().execute(sql, params)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 68, in execute*
>
> return self._execute_with_wrappers(sql, params, many=False,
> executor=self._execute)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 77, in _execute_with_wrappers*
>
> return executor(sql, params, many, context)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 85, in _execute*
>
> return self.cursor.execute(sql, params)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\utils.py",
> line 89, in __exit__*
>
> raise dj_exc_value.with_traceback(traceback) from exc_value
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
> line 83, in _execute*
>
> return self.cursor.execute(sql)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
> line 71, in execute*
>
> return self.cursor.execute(query, args)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 250, in execute*
>
> self.errorhandler(self, exc, value)
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
> line 50, in defaulterrorhandler*
>
> raise errorvalue
>
>   *File
> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
> line 247, in execute*
>
> res = self

Re: Check file input extension

2018-08-28 Thread Tim Graham
You can use FileExtensionValidator:
https://docs.djangoproject.com/en/stable/ref/validators/#django.core.validators.FileExtensionValidator

On Tuesday, August 28, 2018 at 7:35:39 AM UTC-4, René L. Hechavarría wrote:
>
> Hi everyone, i need check file input format in forms.py, someone have any 
> example. Thanks in advance.
>
> My model form:
>
> class TestModelForm(forms.ModelForm):
> class Meta:
> model = TestModel
> exclude = ('id')
>
> widgets = {
> 'doc_1': forms.FileInput(attrs={'class': 'form-control 
> custom-file-input'}), }
>
>

-- 
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/f462176a-aede-4c07-a3b9-f4c273f1c164%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error during GeoDjango tutorial documentaion

2018-08-28 Thread Benjamin Smith
Thank you Jason, that was it.

On Sun, Aug 26, 2018 at 5:49 PM Jason  wrote:

> this might be related:
> https://groups.google.com/forum/#!topic/geodjango/Imkq2DDI7qg
>
> --
> 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/94e6dc8f-ddb3-464a-be35-3bcc526cf5cb%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/CAM4YLWJ2jg6KppL-ADX_1HwuMQyinWzR3aJ4v_LuGtOBLKurYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Foreign key auto-created column position in table

2018-08-28 Thread Vladislav Solovei
Hil.

I have a simple model:

class SipPeer(models.Model):
name = models.CharField(primary_key=True, max_length=40)
type = models.CharField(max_length=10)
defaultuser = models.CharField(max_length=40, blank=True, null=True)
secret = models.CharField(max_length=40, blank=True, null=True)
language = models.CharField(max_length=10, blank=True, null=True)
call_limit = models.IntegerField(db_column='call-limit', blank=True, 
null=True)
context = models.CharField(max_length=40)
subscribecontext = models.CharField(max_length=40, blank=True, 
null=True)
allowtransfer = models.CharField(max_length=20, blank=True, null=True)
disallow = models.CharField(max_length=20, blank=True, null=True)
allow = models.CharField(max_length=20, blank=True, null=True)
host = models.CharField(max_length=40, blank=True, null=True)
ipaddr = models.CharField(max_length=45)
defaultip = models.CharField(max_length=20, blank=True, null=True)
port = models.IntegerField(blank=True, null=True, default=0)
insecure = models.CharField(max_length=20, blank=True, null=True)
nat = models.CharField(max_length=40, blank=True, null=True)
regseconds = models.IntegerField(blank=True, null=True)
useragent = models.CharField(max_length=128, blank=True, null=True)
lastms = models.IntegerField(blank=True, null=True)
*phone* = models.ForeignKey(Phone, models.CASCADE, db_column='realnum', 
blank=True, null=True, related_name='peers', db_index=False)
call_priority = models.IntegerField(blank=True, null=True)
t38pt_udptl = models.CharField(max_length=40, blank=True, null=True)
canreinvite = models.CharField(max_length=16, blank=True, null=True)
fullcontact = models.CharField(max_length=255, blank=True, null=True)
regserver = models.CharField(max_length=255, blank=True, null=True)
deny = models.CharField(max_length=95, blank=True, null=True)
permit = models.CharField(max_length=95, blank=True, null=True)
qualify = models.CharField(max_length=6, blank=True, null=True)
callbackextension = models.CharField(max_length=40, blank=True, 
null=True)
setvar = models.CharField(max_length=40, blank=True, null=True)
t38pt_usertpsource = models.CharField(max_length=40, blank=True, 
null=True)
progressinband = models.CharField(max_length=5, blank=True, null=True)
transport = models.CharField(max_length=24, blank=True, null=True)
trustrpid = models.CharField(max_length=4, blank=True, null=True)

class Meta:
managed = True
db_table = 'sippeers'


After I do "make migrations" and "make migrate", the table column "*realnum*"  
is placed after all columns (but not between lastms and call_priority):
| canreinvite| varchar(16)  | YES  | | NULL|   |
| fullcontact| varchar(255) | YES  | | NULL|   |
| regserver  | varchar(255) | YES  | | NULL|   |
| deny   | varchar(95)  | YES  | | NULL|   |
| permit | varchar(95)  | YES  | | NULL|   |
| qualify| varchar(6)   | YES  | | NULL|   |
| callbackextension  | varchar(40)  | YES  | | NULL|   |
| setvar | varchar(40)  | YES  | | NULL|   |
| t38pt_usertpsource | varchar(40)  | YES  | | NULL|   |
| progressinband | varchar(5)   | YES  | | NULL|   |
| transport  | varchar(24)  | YES  | | NULL|   |
| trustrpid  | varchar(4)   | YES  | | NULL|   |
*| realnum| int(11)  | YES  | MUL | NULL|   |*
++--+--+-+-+---+



Can i somehow override this (default?) behavior?

-- 
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/fa1be9ed-985f-4946-a4ee-1254f3a206db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Foreign key auto-created column position in table

2018-08-28 Thread Matthew Pava
You can probably just modify the migrations file after it is generated.  Just 
move the statements around.  I haven’t tested it myself.
Saying that, why is the order of columns important to you?  We don’t typically 
worry about the order of columns when working with databases.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Vladislav Solovei
Sent: Tuesday, August 28, 2018 8:05 AM
To: Django users
Subject: Foreign key auto-created column position in table

Hil.

I have a simple model:

class SipPeer(models.Model):
name = models.CharField(primary_key=True, max_length=40)
type = models.CharField(max_length=10)
defaultuser = models.CharField(max_length=40, blank=True, null=True)
secret = models.CharField(max_length=40, blank=True, null=True)
language = models.CharField(max_length=10, blank=True, null=True)
call_limit = models.IntegerField(db_column='call-limit', blank=True, 
null=True)
context = models.CharField(max_length=40)
subscribecontext = models.CharField(max_length=40, blank=True, null=True)
allowtransfer = models.CharField(max_length=20, blank=True, null=True)
disallow = models.CharField(max_length=20, blank=True, null=True)
allow = models.CharField(max_length=20, blank=True, null=True)
host = models.CharField(max_length=40, blank=True, null=True)
ipaddr = models.CharField(max_length=45)
defaultip = models.CharField(max_length=20, blank=True, null=True)
port = models.IntegerField(blank=True, null=True, default=0)
insecure = models.CharField(max_length=20, blank=True, null=True)
nat = models.CharField(max_length=40, blank=True, null=True)
regseconds = models.IntegerField(blank=True, null=True)
useragent = models.CharField(max_length=128, blank=True, null=True)
lastms = models.IntegerField(blank=True, null=True)
phone = models.ForeignKey(Phone, models.CASCADE, db_column='realnum', 
blank=True, null=True, related_name='peers', db_index=False)
call_priority = models.IntegerField(blank=True, null=True)
t38pt_udptl = models.CharField(max_length=40, blank=True, null=True)
canreinvite = models.CharField(max_length=16, blank=True, null=True)
fullcontact = models.CharField(max_length=255, blank=True, null=True)
regserver = models.CharField(max_length=255, blank=True, null=True)
deny = models.CharField(max_length=95, blank=True, null=True)
permit = models.CharField(max_length=95, blank=True, null=True)
qualify = models.CharField(max_length=6, blank=True, null=True)
callbackextension = models.CharField(max_length=40, blank=True, null=True)
setvar = models.CharField(max_length=40, blank=True, null=True)
t38pt_usertpsource = models.CharField(max_length=40, blank=True, null=True)
progressinband = models.CharField(max_length=5, blank=True, null=True)
transport = models.CharField(max_length=24, blank=True, null=True)
trustrpid = models.CharField(max_length=4, blank=True, null=True)

class Meta:
managed = True
db_table = 'sippeers'


After I do "make migrations" and "make migrate", the table column "realnum"  is 
placed after all columns (but not between lastms and call_priority):
| canreinvite| varchar(16)  | YES  | | NULL|   |
| fullcontact| varchar(255) | YES  | | NULL|   |
| regserver  | varchar(255) | YES  | | NULL|   |
| deny   | varchar(95)  | YES  | | NULL|   |
| permit | varchar(95)  | YES  | | NULL|   |
| qualify| varchar(6)   | YES  | | NULL|   |
| callbackextension  | varchar(40)  | YES  | | NULL|   |
| setvar | varchar(40)  | YES  | | NULL|   |
| t38pt_usertpsource | varchar(40)  | YES  | | NULL|   |
| progressinband | varchar(5)   | YES  | | NULL|   |
| transport  | varchar(24)  | YES  | | NULL|   |
| trustrpid  | varchar(4)   | YES  | | NULL|   |
| realnum| int(11)  | YES  | MUL | NULL|   |
++--+--+-+-+---+


Can i somehow override this (default?) behavior?

--
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/fa1be9ed-985f-4946-a4ee-1254f3a206db%40googlegroups.com.
For more options, vi

Re: Foreign key auto-created column position in table

2018-08-28 Thread Mikhailo Keda
No need to worry about columns ordering inside db table

-- 
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/a4128ca7-0df5-482e-b520-2bddb9a60033%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Foreign key auto-created column position in table

2018-08-28 Thread Vladislav Solovei
> Saying that, why is the order of columns important to you?  We don’t
> typically worry about the order of columns when working with databases.

We have some old software that use "positional" SQL query parameters (like
a "INSERT INTO table VALUES(...)" ), so we can't add, remove or move the
fields in this table :(



>
вт, 28 серп. 2018 о 16:57 Matthew Pava  пише:

> You can probably just modify the migrations file after it is generated.
> Just move the statements around.  I haven’t tested it myself.
>
> Saying that, why is the order of columns important to you?  We don’t
> typically worry about the order of columns when working with databases.
>
>
>
> *From:* django-users@googlegroups.com [mailto:
> django-users@googlegroups.com] *On Behalf Of *Vladislav Solovei
> *Sent:* Tuesday, August 28, 2018 8:05 AM
> *To:* Django users
> *Subject:* Foreign key auto-created column position in table
>
>
>
> Hil.
>
>
>
> I have a simple model:
>
>
>
> class SipPeer(models.Model):
>
> name = models.CharField(primary_key=True, max_length=40)
>
> type = models.CharField(max_length=10)
>
> defaultuser = models.CharField(max_length=40, blank=True, null=True)
>
> secret = models.CharField(max_length=40, blank=True, null=True)
>
> language = models.CharField(max_length=10, blank=True, null=True)
>
> call_limit = models.IntegerField(db_column='call-limit', blank=True,
> null=True)
>
> context = models.CharField(max_length=40)
>
> subscribecontext = models.CharField(max_length=40, blank=True,
> null=True)
>
> allowtransfer = models.CharField(max_length=20, blank=True, null=True)
>
> disallow = models.CharField(max_length=20, blank=True, null=True)
>
> allow = models.CharField(max_length=20, blank=True, null=True)
>
> host = models.CharField(max_length=40, blank=True, null=True)
>
> ipaddr = models.CharField(max_length=45)
>
> defaultip = models.CharField(max_length=20, blank=True, null=True)
>
> port = models.IntegerField(blank=True, null=True, default=0)
>
> insecure = models.CharField(max_length=20, blank=True, null=True)
>
> nat = models.CharField(max_length=40, blank=True, null=True)
>
> regseconds = models.IntegerField(blank=True, null=True)
>
> useragent = models.CharField(max_length=128, blank=True, null=True)
>
> lastms = models.IntegerField(blank=True, null=True)
>
> *phone* = models.ForeignKey(Phone, models.CASCADE,
> db_column='realnum', blank=True, null=True, related_name='peers',
> db_index=False)
>
> call_priority = models.IntegerField(blank=True, null=True)
>
> t38pt_udptl = models.CharField(max_length=40, blank=True, null=True)
>
> canreinvite = models.CharField(max_length=16, blank=True, null=True)
>
> fullcontact = models.CharField(max_length=255, blank=True, null=True)
>
> regserver = models.CharField(max_length=255, blank=True, null=True)
>
> deny = models.CharField(max_length=95, blank=True, null=True)
>
> permit = models.CharField(max_length=95, blank=True, null=True)
>
> qualify = models.CharField(max_length=6, blank=True, null=True)
>
> callbackextension = models.CharField(max_length=40, blank=True,
> null=True)
>
> setvar = models.CharField(max_length=40, blank=True, null=True)
>
> t38pt_usertpsource = models.CharField(max_length=40, blank=True,
> null=True)
>
> progressinband = models.CharField(max_length=5, blank=True, null=True)
>
> transport = models.CharField(max_length=24, blank=True, null=True)
>
> trustrpid = models.CharField(max_length=4, blank=True, null=True)
>
>
>
> class Meta:
>
> managed = True
>
> db_table = 'sippeers'
>
>
>
>
> After I do "make migrations" and "make migrate", the table column "
> *realnum*"  is placed after all columns (but not between lastms and
> call_priority):
>
> | canreinvite| varchar(16)  | YES  | | NULL|   |
>
> | fullcontact| varchar(255) | YES  | | NULL|   |
>
> | regserver  | varchar(255) | YES  | | NULL|   |
>
> | deny   | varchar(95)  | YES  | | NULL|   |
>
> | permit | varchar(95)  | YES  | | NULL|   |
>
> | qualify| varchar(6)   | YES  | | NULL|   |
>
> | callbackextension  | varchar(40)  | YES  | | NULL|   |
>
> | setvar | varchar(40)  | YES  | | NULL|   |
>
> | t38pt_usertpsource | varchar(40)  | YES  | | NULL|   |
>
> | progressinband | varchar(5)   | YES  | | NULL|   |
>
> | transport  | varchar(24)  | YES  | | NULL|   |
>
> | trustrpid  | varchar(4)   | YES  | | NULL|   |
>
> *| realnum| int(11)  | YES  | MUL | NULL|   |*
>
> ++--+--+-+-+---+
>
>
>
>
>
> Can i somehow override this (default?) behavior?
>
>
>
> --
> You received this message because you are subscribed to the Google Group

Re: Trying to replace a char field with a forgein key feild

2018-08-28 Thread 'Matthew Stroud' via Django users
Thanks for the reply.

This is a perfect coverage of steps 1 through 3 in what I'm doing, but it will 
break when I do step 4. I basically need to extend the model temporarily so the 
code doesn't break (I just thought of this so I'll try to implement it).

Thanks,
Matthew Stroud

On 8/28/18, 5:35 AM, "django-users@googlegroups.com on behalf of Codewise IO" 
 wrote:

You are going to want to create an empty migrations file and edit it to 
make your data transformations. See this article.


https://simpleisbetterthancomplex.com/tutorial/2017/09/26/how-to-create-django-data-migrations.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/986ed380-38dc-4188-ae0e-d97a9a0086b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.





CONFIDENTIALITY NOTICE: This message is intended only for the use and review of 
the individual or entity to which it is addressed and may contain information 
that is privileged and confidential. If the reader of this message is not the 
intended recipient, or the employee or agent responsible for delivering the 
message solely to the intended recipient, you are hereby notified that any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, please notify 
sender immediately by telephone or return email. Thank you.

-- 
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/B4DAE0AD-62EA-4D9E-8425-5B850C4754A3%40overstock.com.
For more options, visit https://groups.google.com/d/optout.


What would be the best way to implement a slider bar with django?

2018-08-28 Thread Geoffrey
Hello,

I'm a complete noob with django and web development in general, but I'm 
trying to figure out how one would go about implementing widgets on my 
website such a slider bars that can make use of the data stored in the 
django databases. For example, if my database stores a bunch of values, I 
might want to extract the minimum and maximum values and create a slider 
bar with those values as the min and max.The user would select a value 
using the slider and then the value would need to be saved to be used on 
other pages. I've gotten a slider bar widget to work using jQuery code I 
found online, but I'm not sure how I would connect this to the data being 
stored within the django framework or if that would even be the right 
strategy. Any tips you could give me would be extremely helpful!


-- 
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/023dc993-d8b2-4572-8b3a-cf5dd57ba8a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany relationship with through_fields and Admin

2018-08-28 Thread Vincent
I figured it out :

from django.db import models
from django.contrib.auth.models import User


# Create your models here.
class Events(models.Model):
 Name = models.CharField(max_length=64)
 Date = models.DateTimeField()
 Description = models.CharField(max_length=200)
 Admin = models.ForeignKey(User, models.SET_NULL, blank=True, null=True, 
related_name='event_admin')
 Status = models.PositiveIntegerField(default=0)
 Attendees = models.ManyToManyField(User, through='Attend',through_fields=(
'events','attendees'))
 
 def __str__(self):
 return self.Name




class Attend(models.Model):
 events = models.ForeignKey(Events, on_delete=models.CASCADE)
 attendees = models.ForeignKey(User, on_delete=models.CASCADE, related_name=
'attendees')
 PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name=
'PlusOne')
 
 class Meta:
 unique_together = (('events', 'attendees'),)

from django.contrib import admin
from .models import Events
from .models import Attend
from django.contrib.auth.models import User




# Register your models here.


class AttendInline(admin.TabularInline):
 model = Attend
 extra = 1


class EventsAdmin(admin.ModelAdmin):
 inlines = [ AttendInline, ]




admin.site.register(Events, EventsAdmin)



Le mardi 28 août 2018 00:44:49 UTC+2, Vincent a écrit :
>
> Hello,
>
> I'm new to Django and i'm trying to made a simple app in which users can 
> attend to an event. I'm trying to have this manageable through the admin 
> site but i get the following error :
> : (admin.E202) fk_name 'attendees' 
> is not a ForeignKey to 'evenement.Events'.
>
> My goal is to have an interface to create the event and add users in the 
> event.
>
> Here are my models :
>
> from django.db import models
> from django.contrib.auth.models import User
>
>
> # Create your models here.
> class Events(models.Model):
>  Name = models.CharField(max_length=64)
>  Date = models.DateTimeField()
>  Description = models.CharField(max_length=200)
>  Admin = models.ForeignKey(User, models.SET_NULL, blank=True, null=True, 
> related_name='event_admin')
>  Status = models.PositiveIntegerField(default=0)
>  Attendees = models.ManyToManyField(User, through='Attend',through_fields
> =('events','attendees'))
>  
>  def __str__(self):
>  return self.Name
>
>
> class Attend(models.Model):
>  events = models.ForeignKey(Events, on_delete=models.CASCADE)
>  attendees = models.ForeignKey(User, on_delete=models.CASCADE)
>  PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name=
> 'PlusOne')
>
> And the admin.py
>
> from django.contrib import admin
> from .models import Events
> from .models import Attend
> from django.contrib.auth.models import User
>
>
>
>
> # Register your models here.
>
>
> class AttendInline(admin.TabularInline):
>  model = Attend
>  fk_name = "attendees"
>  extra = 1
>
>
> class UserAdmin(admin.ModelAdmin):
>  inlines = [ AttendInline, ]
>
>
> class EventsAdmin(admin.ModelAdmin):
>  inlines = [ AttendInline, ]
>
>
>
>
> admin.site.unregister(User)
> admin.site.register(User, UserAdmin)
>
>
> admin.site.register(Events, EventsAdmin)
>
>
> Your help will be much appreciated !
>
> Thank you
>
> Vincent
>

-- 
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/690d5956-6348-4ae3-99bf-030e7df91cdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany relationship with through_fields and Admin

2018-08-28 Thread akash kandpal
What changes you did ?

Regards,
Akash Kandpal.

On Wed, Aug 29, 2018, 12:34 AM Vincent  wrote:

> I figured it out :
>
> from django.db import models
> from django.contrib.auth.models import User
>
>
> # Create your models here.
> class Events(models.Model):
>  Name = models.CharField(max_length=64)
>  Date = models.DateTimeField()
>  Description = models.CharField(max_length=200)
>  Admin = models.ForeignKey(User, models.SET_NULL, blank=True, null=True,
> related_name='event_admin')
>  Status = models.PositiveIntegerField(default=0)
>  Attendees = models.ManyToManyField(User, through='Attend',through_fields
> =('events','attendees'))
>
>  def __str__(self):
>  return self.Name
>
>
>
>
> class Attend(models.Model):
>  events = models.ForeignKey(Events, on_delete=models.CASCADE)
>  attendees = models.ForeignKey(User, on_delete=models.CASCADE,
> related_name='attendees')
>  PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name=
> 'PlusOne')
>
>  class Meta:
>  unique_together = (('events', 'attendees'),)
>
> from django.contrib import admin
> from .models import Events
> from .models import Attend
> from django.contrib.auth.models import User
>
>
>
>
> # Register your models here.
>
>
> class AttendInline(admin.TabularInline):
>  model = Attend
>  extra = 1
>
>
> class EventsAdmin(admin.ModelAdmin):
>  inlines = [ AttendInline, ]
>
>
>
>
> admin.site.register(Events, EventsAdmin)
>
>
>
> Le mardi 28 août 2018 00:44:49 UTC+2, Vincent a écrit :
>>
>> Hello,
>>
>> I'm new to Django and i'm trying to made a simple app in which users can
>> attend to an event. I'm trying to have this manageable through the admin
>> site but i get the following error :
>> : (admin.E202) fk_name 'attendees'
>> is not a ForeignKey to 'evenement.Events'.
>>
>> My goal is to have an interface to create the event and add users in the
>> event.
>>
>> Here are my models :
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>>
>>
>> # Create your models here.
>> class Events(models.Model):
>>  Name = models.CharField(max_length=64)
>>  Date = models.DateTimeField()
>>  Description = models.CharField(max_length=200)
>>  Admin = models.ForeignKey(User, models.SET_NULL, blank=True, null=True,
>> related_name='event_admin')
>>  Status = models.PositiveIntegerField(default=0)
>>  Attendees = models.ManyToManyField(User, through='Attend',through_fields
>> =('events','attendees'))
>>
>>  def __str__(self):
>>  return self.Name
>>
>>
>> class Attend(models.Model):
>>  events = models.ForeignKey(Events, on_delete=models.CASCADE)
>>  attendees = models.ForeignKey(User, on_delete=models.CASCADE)
>>  PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name
>> ='PlusOne')
>>
>> And the admin.py
>>
>> from django.contrib import admin
>> from .models import Events
>> from .models import Attend
>> from django.contrib.auth.models import User
>>
>>
>>
>>
>> # Register your models here.
>>
>>
>> class AttendInline(admin.TabularInline):
>>  model = Attend
>>  fk_name = "attendees"
>>  extra = 1
>>
>>
>> class UserAdmin(admin.ModelAdmin):
>>  inlines = [ AttendInline, ]
>>
>>
>> class EventsAdmin(admin.ModelAdmin):
>>  inlines = [ AttendInline, ]
>>
>>
>>
>>
>> admin.site.unregister(User)
>> admin.site.register(User, UserAdmin)
>>
>>
>> admin.site.register(Events, EventsAdmin)
>>
>>
>> Your help will be much appreciated !
>>
>> Thank you
>>
>> Vincent
>>
> --
> 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/690d5956-6348-4ae3-99bf-030e7df91cdb%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/CAPND-h6%2BfhTXF_vzKLjHofXjg%2BTWrD0NpyefaVKW0Q4q55%3DbPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Sonali Vighne
I have not set password to My MySQL server during installation

On Tuesday, August 28, 2018 at 5:42:30 PM UTC+5:30, Mohammad Aqib wrote:
>
> Set mysql password.
>
> Without password how you can access mysql.
>
> See
>
> DATABASES = {
>
> *'default'*: {
>
> *'ENGINE'*: *'django.db.backends.mysql'*,
>
> *'NAME'*: *'hospital'*,
>
> *'USER'*: *'root'*,
>
> *'PASSWORD'*: *'password'*,
>
> *'HOST'*: *'localhost'*,
>
> *'PORT'*: *'3306'*
> On Tue, 28 Aug 2018, 5:37 pm Sonali Vighne,  > wrote:
>
>>
>> I will paste full error and stack trace here.
>>
>> This is occurred when I am giving “python manage.py migrate” command
>>
>>  
>>
>> Operations to perform:
>>
>>   Apply all migrations: admin, auth, contenttypes, sessions
>>
>> Running migrations:
>>
>> Traceback (most recent call last):
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 83, in _execute*
>>
>> return self.cursor.execute(sql)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>>  
>> line 71, in execute*
>>
>> return self.cursor.execute(query, args)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>  
>> line 250, in execute*
>>
>> self.errorhandler(self, exc, value)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>>  
>> line 50, in defaulterrorhandler*
>>
>> raise errorvalue
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>  
>> line 247, in execute*
>>
>> res = self._query(query)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>  
>> line 411, in _query*
>>
>> rowcount = self._do_query(q)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>  
>> line 374, in _do_query*
>>
>> db.query(q)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>>  
>> line 277, in query*
>>
>> _mysql.connection.query(self, query)
>>
>> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL 
>> syntax; check the manual that corresponds to your MySQL server version for 
>> the right syntax to use near '(6) NOT NULL)' at line 1")
>>
>>  
>>
>> The above exception was the direct cause of the following exception:
>>
>>  
>>
>> Traceback (most recent call last):
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
>>  
>> line 55, in ensure_schema*
>>
>> editor.create_model(self.Migration)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>>  
>> line 312, in create_model*
>>
>> self.execute(sql, params or None)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>>  
>> line 133, in execute*
>>
>> cursor.execute(sql, params)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 100, in execute*
>>
>> return super().execute(sql, params)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 68, in execute*
>>
>> return self._execute_with_wrappers(sql, params, many=False, 
>> executor=self._execute)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 77, in _execute_with_wrappers*
>>
>> return executor(sql, params, many, context)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 85, in _execute*
>>
>> return self.cursor.execute(sql, params)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\utils.py",
>>  
>> line 89, in __exit__*
>>
>> raise dj_exc_value.with_traceback(traceback) from exc_value
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>  
>> line 83, in _execute*
>>
>> return self.cursor.execute(sql)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>>  
>> line 71, in execute*
>>
>> return self.cursor.execute(query, args)
>>
>>   *File 
>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-pack

Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Mohammad Aqib
This password doesn't belong to mysql. This belongs to your database
'hospital'.

On Wed, Aug 29, 2018 at 10:07 AM Sonali Vighne 
wrote:

> I have not set password to My MySQL server during installation
>
> On Tuesday, August 28, 2018 at 5:42:30 PM UTC+5:30, Mohammad Aqib wrote:
>>
>> Set mysql password.
>>
>> Without password how you can access mysql.
>>
>> See
>>
>> DATABASES = {
>>
>> *'default'*: {
>>
>> *'ENGINE'*: *'django.db.backends.mysql'*,
>>
>> *'NAME'*: *'hospital'*,
>>
>> *'USER'*: *'root'*,
>>
>> *'PASSWORD'*: *'password'*,
>>
>> *'HOST'*: *'localhost'*,
>>
>> *'PORT'*: *'3306'*
>> On Tue, 28 Aug 2018, 5:37 pm Sonali Vighne,  wrote:
>>
>>>
>>> I will paste full error and stack trace here.
>>>
>>> This is occurred when I am giving “python manage.py migrate” command
>>>
>>>
>>>
>>> Operations to perform:
>>>
>>>   Apply all migrations: admin, auth, contenttypes, sessions
>>>
>>> Running migrations:
>>>
>>> Traceback (most recent call last):
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 83, in _execute*
>>>
>>> return self.cursor.execute(sql)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
>>> line 71, in execute*
>>>
>>> return self.cursor.execute(query, args)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>> line 250, in execute*
>>>
>>> self.errorhandler(self, exc, value)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>>> line 50, in defaulterrorhandler*
>>>
>>> raise errorvalue
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>> line 247, in execute*
>>>
>>> res = self._query(query)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>> line 411, in _query*
>>>
>>> rowcount = self._do_query(q)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
>>> line 374, in _do_query*
>>>
>>> db.query(q)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
>>> line 277, in query*
>>>
>>> _mysql.connection.query(self, query)
>>>
>>> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your
>>> SQL syntax; check the manual that corresponds to your MySQL server version
>>> for the right syntax to use near '(6) NOT NULL)' at line 1")
>>>
>>>
>>>
>>> The above exception was the direct cause of the following exception:
>>>
>>>
>>>
>>> Traceback (most recent call last):
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
>>> line 55, in ensure_schema*
>>>
>>> editor.create_model(self.Migration)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>>> line 312, in create_model*
>>>
>>> self.execute(sql, params or None)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
>>> line 133, in execute*
>>>
>>> cursor.execute(sql, params)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 100, in execute*
>>>
>>> return super().execute(sql, params)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 68, in execute*
>>>
>>> return self._execute_with_wrappers(sql, params, many=False,
>>> executor=self._execute)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 77, in _execute_with_wrappers*
>>>
>>> return executor(sql, params, many, context)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 85, in _execute*
>>>
>>> return self.cursor.execute(sql, params)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\utils.py",
>>> line 89, in __exit__*
>>>
>>> raise dj_exc_value.with_traceback(traceback) from exc_value
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
>>> line 83, in _execute*
>>>
>>> return self.cursor.execute(sql)
>>>
>>>   *File
>>> "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysq

Re: Error: Not able to create table using models (Backend mysql)

2018-08-28 Thread Sonali Vighne
thank Mohammad :)
I will try it. hope so it would solve my issue.

On Wednesday, August 29, 2018 at 10:32:32 AM UTC+5:30, Mohammad Aqib wrote:
>
> This password doesn't belong to mysql. This belongs to your database 
> 'hospital'.
>
> On Wed, Aug 29, 2018 at 10:07 AM Sonali Vighne  > wrote:
>
>> I have not set password to My MySQL server during installation
>>
>> On Tuesday, August 28, 2018 at 5:42:30 PM UTC+5:30, Mohammad Aqib wrote:
>>>
>>> Set mysql password.
>>>
>>> Without password how you can access mysql.
>>>
>>> See
>>>
>>> DATABASES = {
>>>
>>> *'default'*: {
>>>
>>> *'ENGINE'*: *'django.db.backends.mysql'*,
>>>
>>> *'NAME'*: *'hospital'*,
>>>
>>> *'USER'*: *'root'*,
>>>
>>> *'PASSWORD'*: *'password'*,
>>>
>>> *'HOST'*: *'localhost'*,
>>>
>>> *'PORT'*: *'3306'*
>>> On Tue, 28 Aug 2018, 5:37 pm Sonali Vighne,  wrote:
>>>

 I will paste full error and stack trace here.

 This is occurred when I am giving “python manage.py migrate” command

  

 Operations to perform:

   Apply all migrations: admin, auth, contenttypes, sessions

 Running migrations:

 Traceback (most recent call last):

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
  
 line 83, in _execute*

 return self.cursor.execute(sql)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\mysql\base.py",
  
 line 71, in execute*

 return self.cursor.execute(query, args)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
  
 line 250, in execute*

 self.errorhandler(self, exc, value)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
  
 line 50, in defaulterrorhandler*

 raise errorvalue

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
  
 line 247, in execute*

 res = self._query(query)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
  
 line 411, in _query*

 rowcount = self._do_query(q)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py",
  
 line 374, in _do_query*

 db.query(q)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py",
  
 line 277, in query*

 _mysql.connection.query(self, query)

 _mysql_exceptions.ProgrammingError: (1064, "You have an error in your 
 SQL syntax; check the manual that corresponds to your MySQL server version 
 for the right syntax to use near '(6) NOT NULL)' at line 1")

  

 The above exception was the direct cause of the following exception:

  

 Traceback (most recent call last):

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py",
  
 line 55, in ensure_schema*

 editor.create_model(self.Migration)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
  
 line 312, in create_model*

 self.execute(sql, params or None)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\schema.py",
  
 line 133, in execute*

 cursor.execute(sql, params)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
  
 line 100, in execute*

 return super().execute(sql, params)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
  
 line 68, in execute*

 return self._execute_with_wrappers(sql, params, many=False, 
 executor=self._execute)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
  
 line 77, in _execute_with_wrappers*

 return executor(sql, params, many, context)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\utils.py",
  
 line 85, in _execute*

 return self.cursor.execute(sql, params)

   *File 
 "C:\Users\sonali_vighne\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\u