Re: Django Admin

2023-03-24 Thread Jd Mehra

- 

Clear the browser cache and cookies and then try to log in again. Sometimes 
an old CSRF token can be stored in the browser cache and can cause issues.
- 




On Friday, 24 March 2023 at 07:50:37 UTC+5:30 Ikrombek wrote:

>
> Hello,
> How can I use dental teeth section. For example, do I need to include 32 
> fields from the model to specify 32 teeth, or is there a way to do it in 
> one?
> On Tuesday, March 14, 2023 at 5:39:27 AM UTC+5 Muhammad Juwaini Abdul 
> Rahman wrote:
>
>> In my previous case, I only use this:
>>
>> CSRF_TRUSTED_ORIGINS = ['https://your site url',]
>>
>> On Tue, 14 Mar 2023 at 04:33, Prosper Lekia  wrote:
>>
>>> This is how I deal with all csrf related issues.
>>>
>>> Make sure csrf MiddleWare is in your MiddleWare list 
>>>
>>> 'django.middleware.csrf.CsrfViewMiddleware'
>>>
>>> Add the settings below in your settings.py to prevent all csrf related 
>>> issues
>>>
>>> CSRF_TRUSTED_ORIGINS = ['https://your site url',]
>>> SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'http')
>>> CSRF_USE_SESSIONS = False
>>> CSRF_COOKIE_SECURE = True
>>> SECURE_BROWSER_XSS_FILTER = True
>>>
>>> CORS_ALLOW_CREDENTIALS = True
>>> CORS_ORIGIN_ALLOW_ALL = True
>>>
>>>
>>> SECURE_CONTENT_TYPE_NOSNIFF = True
>>> SECURE_FRAME_DENY = True
>>> SECURE_HSTS_SECONDS = 2592000
>>> SECURE_HSTS_INCLUDE_SUBDOMAINS = True
>>> SECURE_HSTS_PRELOAD = True
>>> X_FRAME_OPTIONS = 'SAMEORIGIN'
>>> SECURE_REFERRER_POLICY = 'same-origin
>>>
>>> On Saturday, March 11, 2023 at 7:04:40 PM UTC+1 James Hunt wrote:
>>>
 Hi there. I am fairly new to Django but have had previous success with 
 creating an app and being able to access the Admin page.
 Recently, if I attempt to access the admin page of a new Django app it 
 throws the CSRF error upon trying to log in!!!

 I have attempted several ways to bypass this error including adding 
 allowed hosts but I cant seem to get past this issue.

 Can someone please provide me with the definitive way of stopping CSRF 
 error when simply trying to access the admin part of Django? I mean there 
 are no post functions that really apply to this feature so I cant 
 understand the CSRF token.

 I cant get past this issue which means I can never access the admin 
 page!!

 Please help.

 Regards

 James

>>> -- 
>>>
>> 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...@googlegroups.com.
>>>
>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/3f7e8ff3-3619-4ddf-8517-0ee3a613ed20n%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/491c2ea0-c962-4392-9777-f95d1e873a62n%40googlegroups.com.


Re: Help on Django + Plotly integration

2023-03-24 Thread Jd Mehra

Create a view that will generate the Plotly chart. In the view, you can use 
the Plotly library to create a chart object and return it as an HTML div 
string. Here is an example view:

from django.shortcuts import render
import plotly.graph_objs as go
import plotly.offline as opy
from django.http import HttpResponse

def my_chart(request):
trace1 = go.Bar(x=[1, 2, 3], y=[4, 5, 6])
data = [trace1]
layout = go.Layout(title='My Chart')
fig = go.Figure(data=data, layout=layout)
div = opy.plot(fig, auto_open=False, output_type='div')
return HttpResponse(div)



On Thursday, 23 March 2023 at 20:20:57 UTC+5:30 Ryan Nowakowski wrote:

> Hey Kumar,
>
> "Not getting the end result" is pretty generic. Where are you stuck 
> specifically? Are there any error messages you're seeing? Have you tried 
> the browser's devtools to see if there are any errors there?
>
> - Ryan
>
>
> On March 23, 2023 6:47:19 AM CDT, Praveen Kumar  
> wrote:
>>
>> Hello Kasper,
>>
>> I have followed following link to get portly chart:
>>
>>
>> https://hackmamba.io/blog/2022/03/quickly-create-interactive-charts-in-django/
>>
>> But I'm not getting end result. Please find below the structure that I 
>> have made. Please let me know if I'm missing anything.
>>
>> [image: Screenshot 2023-03-23 154859.png]
>>
>> Kindly suggest.
>>
>> Thanks & Regards,
>> Praveen
>> On Wednesday, 22 March 2023 at 20:38:55 UTC+5:30 Kasper Laudrup wrote:
>>
>>> On 22/03/2023 15.29, Praveen Kumar wrote: 
>>> > Hi Team, 
>>> > 
>>> > I need help in implementing Plotly with Django for interactive 
>>> dashboards. 
>>> > 
>>> > Please suggest. 
>>> > 
>>>
>>> Try following this: 
>>>
>>> https://googlethatforyou.com?q=plotly%20django 
>>>
>>> Kind regards, 
>>>
>>> Kasper Laudrup 
>>>
>>

-- 
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/21e8e33f-6105-4d0e-8e1d-3f13a0794294n%40googlegroups.com.


Re: Help in django. I want to upload files

2023-03-24 Thread Jd Mehra
yeah, Ryan's comment definitely makes sense

On Thursday, 23 March 2023 at 20:22:17 UTC+5:30 Ryan Nowakowski wrote:

> Your field is called e_resource with an underscore but you're trying to 
> reference it using a dash.
>
>
> On March 22, 2023 11:40:00 PM CDT, Shubhi Pandey  
> wrote:
>>
>> the error is:
>> django.core.exceptions.FieldError: Unknown field(s) (e-resource) 
>> specified for Post
>>
>> models.py
>> class Post(models.Model):
>> e_resource = models.FileField(null=True, 
>>blank=True, 
>>validators=[FileExtensionValidator( ['pdf'] ) 
>> ],upload_to='')
>>
>> views.py
>> def uploadResource_details(request,shop):
>> 
>>  shop = workshop_details.objects.get(w_id=shop)
>>  if request.method == 'POST':
>> form = PostForm(request.POST, request.FILES)
>> if form.is_valid():
>> cdform = form.cleaned_data
>> cdform.save()
>> return HttpResponse("File Uploaded successfully")
>>  else:
>> form = PostForm()
>>  return render(request, 'uploadAttendance.html', {'form': form,'shop' 
>> : shop})
>>
>> forms.py
>> class PostForm(forms.ModelForm):
>> class Meta:
>> model = Post
>> fields = ['e-resource']
>>
>>

-- 
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/4d3c352d-cb02-467f-b8df-82ba098ebde6n%40googlegroups.com.