Re: Page 404 - No Job matches the given query.

2019-09-07 Thread Mclaren Sunday
What are you trying to do?

On Sat, 7 Sep 2019 20:30 Kean,  wrote:

> Hi,
>
> New to Django, Have an issue. the table exists and the view references the
> table however, I still get 404 message.
> I have spent 8 hours trying to resolve, nothing seems to work, please help?
>
> urls.py
>
>  path('businesslogin/businessadmin/busproject',
>  views.project_detail, name='project_detail'),
>
> models.py
>
> class Job(models.Model):
> name = models.CharField(max_length=100)
> budget = IntegerField()
>
> def __str__(self):
> return(self.name)
>
>
> class Category(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE)
> name = models.CharField(max_length=150)
>
> def __str__(self):
> return(self.project)
>
> class Expense(models.Model):
> project = models.ForeignKey(
> Job, on_delete=models.CASCADE, related_name='expenses')
> title = models.CharField(max_length=100)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>
> def __str__(self):
> return(self.project)
>
> views.py
>
> def project_detail(request):
> project = get_object_or_404(Job)
> return render(request, 'projectdetail.html', {'project': project,
> 'expense_list': project.expenses.all()})
>
>
> Error message:
>
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/businesslogin/businessadmin/busproject
> Raised by: core.views.project_detail
>
> No Job matches the given query.
>
>
>
>
> Please can anyone help, with getting the url to connect and resolving this
> error?
>
>
> Best
>
>
> Kean
>
> --
> 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/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%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/CAPm7yyWW0kecfF3Rfu8tYnwfR5FtStj%3D9FWHLfjXQUCVth9WPg%40mail.gmail.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread Mario R. Osorio
*Do not use string interpolation* as proposed by Bhoopesh!!!

Take a look at:

   - SQL injection 
   
   

   - SQL injection protection 
   

 
   and
   - Passing parameters into raw() 
   

   

On Friday, September 6, 2019 at 6:59:04 AM UTC-4, leb dev wrote:
>
> i have a django project that is connected to sql server  database i am 
> trying to write a *select query *  #convert the Django ORM into SQL query
> print("sql query  = ",FilterQuery.query)
>  
> *select * from table name where filed name = user input *
>
>
> *can anyone help me with 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14d1748a-9b51-47b6-83ad-7a4235c0ec9b%40googlegroups.com.


Any Pypi Library to generate Different Reports on Connected models as well.as Different Graph Generation

2019-09-07 Thread Balaji Shetty
Hi everyone

Can any one of you please tell me is there Any Pypi Library to generate
Different Reports on Connected models as well.as Different Graph Generation.

I want to apply aggregate function like sum, count, avg, group by, having,
inner and outer join.


I want to generate in Django  admin only.

Thx in advance...


-- 
Mr Shetty Balaji
Asst. Prof.
IT Department
SGGS I&T
Nanded. My. India

-- 
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/CAECSbOvVkS7uzA5QGWRYMCTQzcv3RD9MTOY-knv6_1njwNC_iw%40mail.gmail.com.


Re: User matching query does not exist.

2019-09-07 Thread Gabriel Stone
Tamam all the best

On Sat, Sep 7, 2019 at 23:12 göktürk sığırtmaç 
wrote:

> I solved it!!! using ObjectDoesNotExist via javatpoint. (
> https://www.javatpoint.com/django-exceptions)
>
> try:
> user = User.objects.get(email=email)
> except ObjectDoesNotExist:
> user = None;
>
>
> 7 Eylül 2019 Cumartesi 23:36:00 UTC+3 tarihinde göktürk sığırtmaç yazdı:
>>
>> I'm trying get user according to email.
>>
>> user = User.objects.get(email=email)
>>
>>
>> if user is none, i will show message. I will check password after. But
>> when i trying login with wrong email address for test i have error "User
>> matching query does not exist.". How can i handle this error to convert
>> message. I have tried this
>>
>> try:
>> user = User.objects.get(email=email)
>> except:
>> user = None;
>>
>>
>> if user is None:
>> messages.warning(request, "Email hatalı")
>> print("email is wrong")
>> return render(request, "login.html", context)
>>
>>
>>  code but my each login attempt, i have message "e mail is wrong"
>>
>>
>> --
> 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/0b36cb1f-d42c-4783-86a7-fcfaf0cbfb99%40googlegroups.com
> 
> .
>
-- 
Gabrielstone😎

-- 
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/CAL-5MpV8y_rfdDxDR7KsgCeD%3Dys3aQALvi_yOGeWOyYqtBrw_Q%40mail.gmail.com.


Re: User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
I solved it!!! using ObjectDoesNotExist via javatpoint. (
https://www.javatpoint.com/django-exceptions) 

try:
user = User.objects.get(email=email)
except ObjectDoesNotExist:
user = None;


7 Eylül 2019 Cumartesi 23:36:00 UTC+3 tarihinde göktürk sığırtmaç yazdı:
>
> I'm trying get user according to email.
>
> user = User.objects.get(email=email)
>
>
> if user is none, i will show message. I will check password after. But 
> when i trying login with wrong email address for test i have error "User 
> matching query does not exist.". How can i handle this error to convert 
> message. I have tried this
>
> try:
> user = User.objects.get(email=email)
> except:
> user = None;
>
>
> if user is None:
> messages.warning(request, "Email hatalı")
> print("email is wrong")
> return render(request, "login.html", context)
>
>
>  code but my each login attempt, i have message "e mail is wrong"
>
>
>

-- 
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/0b36cb1f-d42c-4783-86a7-fcfaf0cbfb99%40googlegroups.com.


Re: User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
Yes i get name email password in register, i get email and password in 
login 

7 Eylül 2019 Cumartesi 23:47:41 UTC+3 tarihinde Gabriel Stone yazdı:
>
> In your user creation form did you add an email field?if you did then only 
> can you query users by their email 
>
> On Sat, Sep 7, 2019 at 22:36 göktürk sığırtmaç  > wrote:
>
>> I'm trying get user according to email.
>>
>> user = User.objects.get(email=email)
>>
>>
>> if user is none, i will show message. I will check password after. But 
>> when i trying login with wrong email address for test i have error "User 
>> matching query does not exist.". How can i handle this error to convert 
>> message. I have tried this
>>
>> try:
>> user = User.objects.get(email=email)
>> except:
>> user = None;
>>
>>
>> if user is None:
>> messages.warning(request, "Email hatalı")
>> print("email is wrong")
>> return render(request, "login.html", context)
>>
>>
>>  code but my each login attempt, i have message "e mail is wrong"
>>
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> Gabrielstone😎
>

-- 
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/449722c8-b307-4001-aac6-cf4102e30bb4%40googlegroups.com.


Re: User matching query does not exist.

2019-09-07 Thread Gabriel Stone
In your user creation form did you add an email field?if you did then only
can you query users by their email

On Sat, Sep 7, 2019 at 22:36 göktürk sığırtmaç 
wrote:

> I'm trying get user according to email.
>
> user = User.objects.get(email=email)
>
>
> if user is none, i will show message. I will check password after. But
> when i trying login with wrong email address for test i have error "User
> matching query does not exist.". How can i handle this error to convert
> message. I have tried this
>
> try:
> user = User.objects.get(email=email)
> except:
> user = None;
>
>
> if user is None:
> messages.warning(request, "Email hatalı")
> print("email is wrong")
> return render(request, "login.html", context)
>
>
>  code but my each login attempt, i have message "e mail is wrong"
>
>
> --
> 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/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com
> 
> .
>
-- 
Gabrielstone😎

-- 
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/CAL-5MpWb6fpUZs%3Dvrztc%3DjN8RaUNYax1nwGXegR1J-cG0Mk2dA%40mail.gmail.com.


User matching query does not exist.

2019-09-07 Thread göktürk sığırtmaç
I'm trying get user according to email.

user = User.objects.get(email=email)


if user is none, i will show message. I will check password after. But when 
i trying login with wrong email address for test i have error "User 
matching query does not exist.". How can i handle this error to convert 
message. I have tried this

try:
user = User.objects.get(email=email)
except:
user = None;


if user is None:
messages.warning(request, "Email hatalı")
print("email is wrong")
return render(request, "login.html", context)


 code but my each login attempt, i have message "e mail is wrong"


-- 
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/985ce3b9-2810-48ef-9840-e18515109f4b%40googlegroups.com.


Page 404 - No Job matches the given query.

2019-09-07 Thread Kean
Hi,

New to Django, Have an issue. the table exists and the view references the 
table however, I still get 404 message.
I have spent 8 hours trying to resolve, nothing seems to work, please help?

urls.py

 path('businesslogin/businessadmin/busproject',
 views.project_detail, name='project_detail'),

models.py

class Job(models.Model):
name = models.CharField(max_length=100)
budget = IntegerField()

def __str__(self):
return(self.name)


class Category(models.Model):
project = models.ForeignKey(
Job, on_delete=models.CASCADE)
name = models.CharField(max_length=150)

def __str__(self):
return(self.project)

class Expense(models.Model):
project = models.ForeignKey(
Job, on_delete=models.CASCADE, related_name='expenses')
title = models.CharField(max_length=100)
amount = models.DecimalField(max_digits=8, decimal_places=2)
category = models.ForeignKey(Category, on_delete=models.CASCADE)

def __str__(self):
return(self.project)

views.py

def project_detail(request):
project = get_object_or_404(Job)
return render(request, 'projectdetail.html', {'project': project, 
'expense_list': project.expenses.all()})


Error message:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/businesslogin/businessadmin/busproject
Raised by: core.views.project_detail

No Job matches the given query.




Please can anyone help, with getting the url to connect and resolving this 
error?


Best 


Kean

-- 
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/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread David Grant
On Sat., Sep. 7, 2019, 8:21 a.m. Daniel Roseman, 
wrote:

> On Friday, 6 September 2019 20:39:58 UTC+1, Bhoopesh sisoudiya wrote:
>>
>> Hi Lev dev,
>>
>> Write your query like this
>>
>>
>> sqlRawQuery = "Your query ... Field name= {}".format (userInput)
>>
>> Thanks
>> Bhoopesh Kumar
>>
>>
>>>
>>>
> No. Do **not** do this, ever.
>
> Use SQL parameters:
>
> query = 'SELECT * FROM whatever WHERE name = %s'
> cursor.execute(query, (user_input,))
>
> Bhoopesh please stop giving bad unsafe advice like this.
> --
> Daniel.
>

Bhoopesh

The reason is that the user input could be used to do something
dangerous It's called SQL injection. The solution be Daniel prevents
this. Look it up...

Dave

-- 
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/CAJPFr9RNJp%3DgfKBOC3ApdHu8nbaRhazYNDG%2BzJ3V9-q9-xroQA%40mail.gmail.com.


Re: Role Based Access Control for different API methods in Django REST Framework

2019-09-07 Thread gulo loki
in your viewset class,you could  rewrite   get_permissions to set which
permissions you want on action
def get_permissions(self, *args, **kwargs):
if self.action == 'create':
self.permission_classes = (AllowAny,)
elif self .action == 'login':
self.permission_classes = (AllowAny,)

Azar Mohamed  于2019年9月7日周六 下午11:37写道:

> I am creating REST API for Product, which has following Permission,
> (create_product, view_product, edit_product). In my Project I am having
> various users with different roles (Ex: Producer, Retailer,
> Consumer,...etc). I am assigning permission to individual Roles. I am using
> Django Group Permission
>
> Example: The "Producer" role has "create_product" and "view_product"
> permission. The "Retailer" role has "edit_product" permission. The
> "Consumer" role has no permission.
>
> I want to restrict the Access based on the permission code. I need a
> generic approach to solve this. I want to use the same approach for
> different views with different permission codes.
>
> In my view.py,
>
> class Product(viewsets.ModelViewSet):
>
>  serializer_class = ProductSerializer
>  queryset = Product.objects.all()
>
> In settings.py, I have added following code.
>
>  REST_FRAMEWORK = {
>  'DEFAULT_PERMISSION_CLASSES': (
>'rest_framework.permissions.IsAuthenticated',
>  ),
>  'DEFAULT_AUTHENTICATION_CLASSES': (
>'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
>'rest_framework.authentication.BasicAuthentication',
>'rest_framework.authentication.SessionAuthentication',
>  ),
>  }
>
> --
> 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/b67aed04-a096-4c1d-a453-b0be1274dc83%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/CAPO6ddikduNXS2_U%3Ddy_0db_jM19dhQUKeKJ7Sj%2BPAU8eWknxQ%40mail.gmail.com.


Error 'CreateView is missing a QuerySet'

2019-09-07 Thread Febvre Antoine
Hi everyone,

I'm trying to get an account app with custom authentification and 
registration.
Admin user can access to django admin site, simple user with required 
permission can add new users through a CreateView and a form.

But, I get this quite annoying error message which tell me 'CreateView is 
missing a QuerySet' . I have no idea how to fix it.
I understand from the doc that queryset reference model objects and that if 
model is alreay define, then it's useless, i feel wrong here ...

Can someone explain me clearly what are those queryset and help me fixing 
my code below ?

#models.py

class UserProfileManager(BaseUserManager):

def create_user(self, password=None, **kwargs):
user = self.model(**kwargs)
user.set_password(password)
user.save(using=self.db)
return user

def create_superuser(self, password=None, **kwargs):
user = self.create_user(password=password)
user.is_admin = True
user.save(using=self.db)
return user


class UserProfile(AbstractBaseUser):
__MAX_LENGTH = 100
username = models.CharField(max_length=__MAX_LENGTH, verbose_name="Nom 
d'utilisateur", unique=True)
first_name = models.CharField(max_length=__MAX_LENGTH, 
verbose_name="Prénom", default="")
last_name = models.CharField(max_length=__MAX_LENGTH, verbose_name="Nom", 
default="")
email = models.EmailField(max_length=__MAX_LENGTH, verbose_name="Adresse 
e-mail", default="")
perm_on_user = models.BooleanField(verbose_name="Gestion des utilisateurs", 
default=False)
perm_on_news = models.BooleanField(verbose_name="Gestion de la newsletter", 
default=False)
is_admin = models.BooleanField(verbose_name="Administrateur", default=False)

USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['first_name', 'last_name', 'email', 'perm_on_user', 
'perm_on_news', 'is_admin', ]

object = UserProfileManager()

class Meta:
verbose_name = "Utilisateur"

def has_perm(self, perm, obj=None):
return True

def has_module_perms(self, app_label):
return True

@property
def is_staff(self):
return self.is_admin
#admin.py


class UserCreationForm(forms.ModelForm):
password = forms.CharField(label='Mot de passe', widget=forms.PasswordInput)
password_confirm = forms.CharField(label='Confirmation du mot de passe', 
widget=forms.PasswordInput)

class Meta:
model = UserProfile
fields = ('first_name', 'last_name', 'email', 'perm_on_user', 
'perm_on_news', 'is_admin',)

def clean_password_confirm(self):
# Check that the two password entries match
password = self.cleaned_data.get("password")
password_confirm = self.cleaned_data.get("password_confirm")
if password and password_confirm and password != password_confirm:
raise forms.ValidationError("Les mots de passes ne correcpondent 
pas")
return password

def save(self, commit=True):
# Save the provided password in hashed format
user = super().save(commit=False)
user.set_password(self.cleaned_data["password"])
if commit:
user.save()
return user


class UserModificationForm(forms.ModelForm):
"""A form for updating users. Includes all the fields on
the user, but replaces the password field with admin's
password hash display field.
"""

password = forms.CharField(label='Mot de passe', widget=forms.PasswordInput)
password_confirm = forms.CharField(label='Confirmation du mot de passe', 
widget=forms.PasswordInput)

class Meta:
model = UserProfile
fields = ('first_name', 'last_name', 'email', 'perm_on_user', 
'perm_on_news', 'is_admin',)

def clean_password_confirm(self):
# Check that the two password entries match
password = self.cleaned_data.get("password")
password_confirm = self.cleaned_data.get("password_confirm")
if password and password_confirm and password != password_confirm:
raise forms.ValidationError("Les mots de passes ne correcpondent 
pas")
return password

def save(self, commit=True):
# Save the provided password in hashed format
user = super().save(commit=False)
user.set_password(self.cleaned_data["password"])
if commit:
user.save()
return user


class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
form = UserModificationForm
add_form = UserCreationForm

# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('username', 'first_name', 'last_name', 'email', 
'perm_on_user', 'perm_on_news', 'is_admin',)
list_filter = ('perm_on_user', 'perm_on_news', 'is_admin')
fieldsets = (
(None, {'fields': (
'username', 'password', 'password_confirm', 'first_name', 'last_name', 
'

404 error

2019-09-07 Thread arpit Dubey
I have followed all the steps for creating our first app  polls but it is 
showing the error of 404 
could you please help me to finding it out why it is happening there after 
copying each and every step from documentation.

-- 
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/38de38f7-9418-4ce5-8132-4bc96e730de4%40googlegroups.com.


Role Based Access Control for different API methods in Django REST Framework

2019-09-07 Thread Azar Mohamed
I am creating REST API for Product, which has following Permission, 
(create_product, view_product, edit_product). In my Project I am having various 
users with different roles (Ex: Producer, Retailer, Consumer,...etc). I am 
assigning permission to individual Roles. I am using Django Group Permission

Example: The "Producer" role has "create_product" and "view_product" 
permission. The "Retailer" role has "edit_product" permission. The "Consumer" 
role has no permission.

I want to restrict the Access based on the permission code. I need a generic 
approach to solve this. I want to use the same approach for different views 
with different permission codes.

In my view.py,

class Product(viewsets.ModelViewSet):

 serializer_class = ProductSerializer
 queryset = Product.objects.all()

In settings.py, I have added following code.

 REST_FRAMEWORK = {
 'DEFAULT_PERMISSION_CLASSES': (
   'rest_framework.permissions.IsAuthenticated',
 ),
 'DEFAULT_AUTHENTICATION_CLASSES': (
   'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
   'rest_framework.authentication.BasicAuthentication',
   'rest_framework.authentication.SessionAuthentication',
 ),
 }

-- 
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/b67aed04-a096-4c1d-a453-b0be1274dc83%40googlegroups.com.


Re: how to pass user input into raw sql query ?

2019-09-07 Thread Daniel Roseman
On Friday, 6 September 2019 20:39:58 UTC+1, Bhoopesh sisoudiya wrote:
>
> Hi Lev dev,
>
> Write your query like this 
>
>
> sqlRawQuery = "Your query ... Field name= {}".format (userInput)
>
> Thanks
> Bhoopesh Kumar
>  
>
>>
>>
No. Do **not** do this, ever. 

Use SQL parameters: 

query = 'SELECT * FROM whatever WHERE name = %s'
cursor.execute(query, (user_input,))

Bhoopesh please stop giving bad unsafe advice like this. 
--
Daniel. 

-- 
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/7bb94edb-c558-4dba-bb17-4e71e22b6685%40googlegroups.com.


Re: django.db.utils.OperationalError: no such table:

2019-09-07 Thread Suraj Thapa FC
1. python manage.py migrate - - run-syncdb

On Sat, 7 Sep, 2019, 6:30 PM Arnav Rastogi,  wrote:

> 1. i remove the db.sqlite file and pycache
>
> 2. re run the makemigrations and migrate command
>
>
> --
> 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/7f509bea-e0ff-446d-adca-673d9d6999db%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/CAPjsHcHWmT02dOr0kX5rQ1XQarO26F4pScj_uOZ327uOmpZgJA%40mail.gmail.com.


django.db.utils.OperationalError: no such table:

2019-09-07 Thread Arnav Rastogi
1. i remove the db.sqlite file and pycache  

2. re run the makemigrations and migrate command


-- 
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/7f509bea-e0ff-446d-adca-673d9d6999db%40googlegroups.com.


Re: AttributeError 'QuerySet' object has no attribute 'expenses'

2019-09-07 Thread Kean
Hi,

removing did, not work, still getting same error.
Welcome any other help from the wider community in reference to this issue.
best,

Kean

On 6 Sep 2019, at 22:26, Bhoopesh sisoudiya  wrote:

> Try after removing related_name='expenses' from Expenses model.
> 
> On Sat, Sep 7, 2019, 2:28 AM Kean  wrote:
> Hi Bhoopesh,
> 
> If this is a simple issue to resolve, please provide code which works.
> Reading an abstract reference, is welcome, but is not really helping to solve 
> as one can always reference a source. 
> 
> Please advise solution that works, and then reference a learning resource, so 
> user knows where to go for learning, but with solution in hand.
> 
> Best,
> 
> Kean
> 
> On 6 Sep 2019, at 21:54, Bhoopesh sisoudiya  wrote:
> 
>> https://stackoverflow.com/questions/31237042/whats-the-difference-between-select-related-and-prefetch-related-in-django-orm
>> 
>> 
>> On Sat, Sep 7, 2019, 2:20 AM Kean  wrote:
>> Don’t understand?
>> 
>> On 6 Sep 2019, at 21:41, Bhoopesh sisoudiya  wrote:
>> 
>>> 'project' inside select_related() is foreign key in Expenses modal of 
>>> Project modal.
>>> 
>>> On Sat, Sep 7, 2019, 2:07 AM Kean  wrote:
>>> Ok,
>>> 
>>> Updated to below, and am still getting the same error:
>>> 
>>> def projectdetail(request):
>>> projectList = Project.objects.all()
>>> projectExpenseDetails = Expense.objects.select_related('project').all()
>>> return render(request, 'busprojectdetail.html', {'project': project, 
>>> 'expense_list': projectExpenseDetails})
>>> 
>>> Exception Type: NameError
>>> Exception Value:
>>> name 'project' is not defined
>>> Exception Location: 
>>> /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in projectdetail, 
>>> line 239
>>> Best,
>>> Kean
>>> 
>>> 
>>> On 6 Sep 2019, at 21:32, Bhoopesh sisoudiya  wrote:
>>> 
 Sorry my mistake
 
 
 def projectdetail(request):
 projectList = Project.objects.all()
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': 
 projectList, 'expense_list': projectExpenseDetails})
 
 
 On Sat, Sep 7, 2019, 1:55 AM Kean  wrote:
 Hi Ok,
 
 I updated as advised.
 
 views.py
 
 def projectdetail(request):
 projectExpenseDetails = Expense.objects.select_related('project').all()
 return render(request, 'busprojectdetail.html', {'project': project, 
 'expense_list': projectExpenseDetails})
 
 I get new error
 Exception Type:NameError
 Exception Value:   
 name 'project' is not defined
 Exception Location:
 /Users/ProductionEnv/Desktop/test/test1/dev/core/views.py in 
 projectdetail, line 238
 
 
 Please advise?
 
 Best,
 
 Kean
 On 6 Sep 2019, at 21:19, Bhoopesh sisoudiya  wrote:
 
> projectExpnseDetails
 
>>> 
>> 
> 

-- 
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/43C89EFD-1D4C-4B03-962E-898124A8D96D%40gmail.com.