djngo unittest to use "real" database.

2020-09-06 Thread django-newbie
Hi All,

I am currently writing test cases for views, Which eventually uses database 
also.
By default a test database is being created and removed after test are run.

As the database itself is development database, I don't want my test to 
create a separate db but use exciting only.
Also I will like to bring to your notice, that in my environment, database 
are created and provided and django can't run migration or create database.

Regards,
Arjit 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e6fd0155-ee4e-46f7-8e81-74983d388536n%40googlegroups.com.


django widget radio button error save is not touch

2020-09-06 Thread carlos
Hi, i have a problem when save a field in radio button
in my models have this
CHOICES_OPTIONS = (
 (1, 'Yes'),
(2, 'No'),
)

class MyModels(...):
   myfield = models.IntegerField(choices=CHOICES_OPTIONS, null=True,
blank=True)
   

class MyModelsForm()
   myfield = forms.ChoiceField(widget=forms.RadioSelect,
choices=CHOICES_OPTIONS,
   required=False)

but when save the forms in my views this sends this error:

Field 'myfield' expected a number but got ''.

sometimes the user does not select anything neither yes nor no, the radio
button they won't touch it

How can I make that null field be saved without any value and it does not
throw me that 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO3gTb%2BdU8dZG-WErBhWmZvArTiAKM_21mxqw5__7Nmavw%40mail.gmail.com.


Re: Django+DjangoRestFramework+React+Redux open source projects

2020-09-06 Thread Shishir Jha
And here are the two repos which represent frontend and backend for a react
and django app that I built during a hiring process. Note that this is a
very beginner level. I had to submit it within 10 days. But it covers all
the basics like rest apis, authentication,authorization, calling backend
rest api from react frontend. I have not done state management with redux
or context. I have simply passed props up or down. You can implement redux
and learn yourself. If anyone wants to submit the PR after implementing
redux or context api or recoil I will merge it in master. It will be a good
learning experience.

https://github.com/shishirjha/keeper_frontend  (frontend)
https://github.com/shishirjha/notesKeeper  (backend)

On Sun, Sep 6, 2020 at 9:54 AM Shishir Jha  wrote:

> https://github.com/justdjango/django-react-ecommerce
>
> There are many more you can find it on searching google.
>
> On Sun, 6 Sep 2020, 9:43 am Yogendra Yadav, 
> wrote:
>
>> thank you, can you please suggest some more
>>
>> On Sun, Sep 6, 2020 at 3:01 AM Shishir Jha 
>> wrote:
>>
>>> Look for gothinkster in github
>>>
>>> On Sat, 5 Sep 2020, 10:20 pm Yogendra Yadav, 
>>> wrote:
>>>
 Please suggest open source projects to learn subject combination

 --
 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 view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/4af9efdc-1b3a-4170-93e3-403cc2b2e241n%40googlegroups.com
 
 .

>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2BC7wFTiSdqFckigW%3Dq4kq6y4CK32MaEXg5XbLwHpgy6c4k8EA%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANiv6f3VWqmKK1B4zc-or3FkULOkmkWYwoHfNiwYTC3M-6jJ5Q%40mail.gmail.com
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BC7wFSXY_7kek2bdS7Td0G7eJPj%2Bt0d-mOz-pcZHEk0XrhGBw%40mail.gmail.com.


Is this a bug on manage.py command: no such table: auth_permission?

2020-09-06 Thread cta...@gmail.com


Hi,

I am getting an error django.db.utils.OperationalError: no such table: 
auth_permission on my manage.py command (makemigrations/migrate/runserver)

I am not sure if this consider a bug or is it a problem of my setup. So I 
am checking here before filing bug report to the ticket tracker.

To reproduce the error:

   - Django==2.2.15 
   - djangorestframework==3.11.1 

Steps:

   1. Copy code below. 
   2. Run python manage.py makemigrations -> error. 

or

   1. Remove the code from urls.py that will cause the error. 
   2. Run python manage.py makemigrations -> success without error. 
   3. Add back the removed code from step 1. 
   4. Run python manage.py migrate -> this will trigger the same error. 
   Imagine we deployed our project to server and run migrate for the very 
   first time. 

customuser/models.py

from django.contrib.auth.models import AbstractUser, Permission, UserManager
from django.db.models import Q
from django.db import models

class CustomUserManager(UserManager):

def get_users(self):
perm = Permission.objects.get(codename='can_view_something')
users = self.filter(Q(groups__permissions=perm) | 
Q(user_permissions=perm))
return users

class CustomUser(AbstractUser):
objects = CustomUserManager()

permissions = (
('can_view_something', 'Can View Something'),
)

customuser/views.py

from django.contrib.auth import get_user_model
from rest_framework import generics, serializers
from .models import CustomUser

class UserSerializer(serializers.ModelSerializer):
class Meta(object):
model = get_user_model()
fields = ('id', 'username',)

class SomeUserView(generics.ListAPIView):
queryset = get_user_model().objects.get_users()
serializer = UserSerializer

myproject/urls.py (Root urls.py)

from django.contrib import admin
from django.urls import path
from customuser import views

urlpatterns = [
path('admin/', admin.site.urls),
path('users', views.SomeUserView.as_view(), name="some-user-view")
]

Exact traceback


Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/__init__.py",
 line 381, in execute_from_command_line
utility.execute()
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/__init__.py",
 line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/base.py",
 line 323, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/base.py",
 line 361, in execute
self.check()
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/base.py",
 line 390, in check
include_deployment_checks=include_deployment_checks,
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/management/base.py",
 line 377, in _run_checks
return checks.run_checks(**kwargs)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/checks/registry.py",
 line 72, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/checks/urls.py",
 line 13, in check_url_config
return check_resolver(resolver)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/core/checks/urls.py",
 line 23, in check_resolver
return check_method()
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/urls/resolvers.py",
 line 399, in check
for pattern in self.url_patterns:
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/utils/functional.py",
 line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/urls/resolvers.py",
 line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/utils/functional.py",
 line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"/Users/me/.virtualenvs/reproducemigrateerror-hrGW_V7T/lib/python3.7/site-packages/django/urls/resolvers.py",
 line 577, in urlconf_module
return import_module(self.urlconf_name)
  File