Saturday, August 31, 2019

styling tables in django

Hi,

New to Django, appreciate the guidance,

I'm looking to style template so both header and data records are note wrapped.
please see current setup.

Please can anyone help with the template code, appreciate, it's not quite django, but more bootstrap4 django.

Best,
K





--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ec35ddf7-12ff-47cc-a41e-4b6736faed22%40googlegroups.com.

Post request in foreign key details by providing id

Hi Folks,
At the time of post request I want to provide only ID and then I want to fetch the details related to that ID  from another model and then I want to commit all the deatils inside my ForeignKey table,Please guys tell me How can I do that bu using django rest framewoek?


models.py
class DoctorProfile(models.Model):
    # doctor_id = models.IntegerField(primary_key=True)
    user = models.OneToOneField(User, on_delete = models.CASCADE,related_name = 'user_profile')
    specialities = models.CharField(max_length=100)
    start_time = models.TimeField(null = True)
    end_time = models.TimeField(null = True)
    cost = models.DecimalField(max_digits=6, decimal_places=2)
    craeted_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)

    def __str__(self):
        return self.user.username



class Hospital(models.Model):
    # hospital_id = models.IntegerField(primary_key=True)
    doctor_name = models.ForeignKey(DoctorProfile,on_delete=models.DO_NOTHING)
    permanent = models.BooleanField(default = False)
    consultant =  models.BooleanField(default = False)
    craeted_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)



I want to add profile details inside Hospital table ForeignKey column, but I want to post opeartion by using this format:

{
     "id":2,
    " permanent": true,
     }


Thanks 


Regards,
Soumen

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYoYA1nrT7Ne%3DvT1%3Djmk1Omf%3DFo%2BiyuA_ZxsTd152t4EA%40mail.gmail.com.

Re: Reverse for 'modification' with no arguments not found issue





The line with a problem is that one

    return render(request, 'insertion/modification.html', locals())


And I really can't figure it out why, according the fact that "locals()" contains my variable and even if I send directly my variable instead, I get the same !

There's probably a URL tag in that template that is missing a variable or has a typo in the variable reference. The error is complaining about a reverse call, not a render call. It might be in a different part of the traceback or error page. You need to look closer at the original error page, it probably cites something in the modification.html template, and you didn't post that one.

-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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXbr%3DtVaF5HredGqGK0LQ_9SiHuNKcv1%2Be0HFn1cX-zEQ%40mail.gmail.com.

Re: Is it a good practice to store all static data dynamically in database rather?

There are already servers that are very good at handling static files, such as nginx, apache, or amazon S3.
Django will never be better at handling static files compared to those servers, as on production, Django will always be put behind those web servers.

Putting static files on database, means Django will be needed to handle them, which is not efficient.


On Sat, Aug 31, 2019 at 3:35 AM Sapna Tomar <medreams6@gmail.com> wrote:
Hey! I'm making a static website (showcasing a hobby club of my college) using Django. I have used database for storing most of the content like photos, or events since they have multiple instances. Will it also be okay to save all the rest of the content which does not necessarily have more than one instance, like 'contact info' at the end of the page, or an 'About' of the page?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b86e8d4-6d37-4c85-b3d4-fb7283565fed%40googlegroups.com.


--
Regards,

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAN7EoAa4TUKTbVuXFRLOZet3z-8rjkjw4_QB6W9_jP6utVc7DA%40mail.gmail.com.

Please help me to solve the error

There is an error when i add url to url.py. The url.py file is as follow-
from django.contrib import admin
from django.urls import path, include


urlpatterns = [
path('admin/', admin.site.urls),
path('polls/', include('polls.urls')),
]
when i run the code in terminal : 'python manage.py runserver' ; then the follwing error is displayed in the terminal -

django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'polls.urls' from 'C:\\Users\\Administrator\\PycharmProjects\\website2\\mysite\\polls\\urls.py'>' does
not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

Please help me to solve the error

Regards,
Django user

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e77ae50b-dbdb-447a-9e91-b04e996197c9%40googlegroups.com.

Friday, August 30, 2019

Re: Is it a good practice to store all static data dynamically in database rather?

Hello there!

The images you mentioned you can store in the static folder of your Django project. This is the "default" location.Things such logo image, icons, JS and CSS files are placed in this folder, you can separete them by types. 






Em Sex, 30 de ago de 2019 17:35, Sapna Tomar <medreams6@gmail.com> escreveu:
Hey! I'm making a static website (showcasing a hobby club of my college) using Django. I have used database for storing most of the content like photos, or events since they have multiple instances. Will it also be okay to save all the rest of the content which does not necessarily have more than one instance, like 'contact info' at the end of the page, or an 'About' of the page?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b86e8d4-6d37-4c85-b3d4-fb7283565fed%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAwGMa0gqpcL6TXeCkcffZ4nYgaRk52owYrG%2Bi_QiP2Pv%3DMz7g%40mail.gmail.com.

Re: Unsynchronized sequence

Hi.

You really need to give more context than that.

What you exactly did? What you expected to happen? What was the actual outcome? Preferably with all commands and code you used with responses you got.

ke 28. elok. 2019 klo 16.49 Ezequias Rocha <ezequias.rocha@gmail.com> kirjoitti:
Hello everyone

I am using django rest framework and I noticed that even I changing the current sequence in my database (PostgreSQL) the next element in database (generated by django) isn't created as I expect.

Could someone tell me if you have experienced this before?

Best regards
Ezequias

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/60700f56-aed8-44f3-902a-d084b13407df%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHn91oeRPekNb-FgCrbFKXZCYctQaF%2ByAitnJeZvSbdVvJVkQw%40mail.gmail.com.

Re: How to change the label for username to 'username/email' in login page in Django

You can use a label or help text. 

https://docs.djangoproject.com/en/2.2/ref/forms/fields/#help-text



On Friday, August 30, 2019 at 12:28:47 PM UTC-5, Sandip Nath wrote:
I am building a car rental website with Django. Currently working on user authentication.The user can either use his/her username/email and password to login.It's working fine. My question is, how will I change the label for username field to "username/email" so that the user can understand that either username or email can be entered. I cannot  make changes in the login.html template because I have used there {{ form.as_p }} tag and the concerned portion in my forms.py file has:

    class LoginForm(forms.Form):
        username = forms.CharField()
        password = forms.CharField(widget=forms.PasswordInput)

I am not able to understand where to make changes. Please help.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0000d92a-4340-471a-a853-eb2a4fc73a82%40googlegroups.com.

Is it a good practice to store all static data dynamically in database rather?

Hey! I'm making a static website (showcasing a hobby club of my college) using Django. I have used database for storing most of the content like photos, or events since they have multiple instances. Will it also be okay to save all the rest of the content which does not necessarily have more than one instance, like 'contact info' at the end of the page, or an 'About' of the page?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b86e8d4-6d37-4c85-b3d4-fb7283565fed%40googlegroups.com.

Re: How to change the label for username to 'username/email' in login page in Django

If guess you are using HTML to create the form. So, I believe that Type  = 'Text' and Type = 'email'. May be. Please cross cehck

Regards,
Amitesh Sahay


On Friday, 30 August, 2019, 10:59:19 pm IST, Sandip Nath <techsandip@gmail.com> wrote:


I am building a car rental website with Django. Currently working on user authentication.The user can either use his/her username/email and password to login.It's working fine. My question is, how will I change the label for username field to "username/email" so that the user can understand that either username or email can be entered. I cannot  make changes in the login.html template because I have used there {{ form.as_p }} tag and the concerned portion in my forms.py file has:

    class LoginForm(forms.Form):
        username = forms.CharField()
        password = forms.CharField(widget=forms.PasswordInput)

I am not able to understand where to make changes. Please help.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d67736f6-0b96-490d-8d73-bdcb476cd048%40googlegroups.com.

How to change the label for username to 'username/email' in login page in Django

I am building a car rental website with Django. Currently working on user authentication.The user can either use his/her username/email and password to login.It's working fine. My question is, how will I change the label for username field to "username/email" so that the user can understand that either username or email can be entered. I cannot  make changes in the login.html template because I have used there {{ form.as_p }} tag and the concerned portion in my forms.py file has:

    class LoginForm(forms.Form):
        username = forms.CharField()
        password = forms.CharField(widget=forms.PasswordInput)

I am not able to understand where to make changes. Please help.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d67736f6-0b96-490d-8d73-bdcb476cd048%40googlegroups.com.

Re: TypeError: expected string or bytes-like object

Code pls

On Fri, 30 Aug, 2019, 6:06 PM Soumen Khatua, <soumenkhatua258@gmail.com> wrote:
Hi Folks,

After do some modification in models.py like I remove some column and add some column in my models,now I'm getting this error:

TypeError: expected string or bytes-like object


Please tell me how can i solve this problem?


Thank You

Regards,
Soumen

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WaHcREmx0Nw8NTXoxdC-fKrQKQuVMfdk5DmGz6%3DTd4yFw%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPjsHcHtxZa8wTY%2Bb0EpAOXgu4PfrSM232OXS9V6pmt-Lve%3DdQ%40mail.gmail.com.

Re: Channels: launching a custom co-routine from SyncConsumer

Sorry my dalay also. My problem is that I was looking for a wrong PostgreSQL sequence. My fault, my totally fault.

Django rocks!

Sincerely
Ezequias Rocha

On Wednesday, August 28, 2019 at 11:26:25 AM UTC-3, Dan Merillat wrote:
On 8/15/19 11:10 PM, Andrew Godwin wrote:
> SyncConsumer isn't async - it runs inside a separate synchronous thread.
> You'll need to get the event loop from the other thread and use
> call_soon_threadsafe instead!

Sorry for the delay in getting back to you, it took me a while to go
through the different layers to find the appropriate event loop.  Thank
you for the pointer, it got me headed down what I hope is the right path.

SyncConsumer is based on AsyncConsumer, with dispatch() ultimately
wrapped in SyncToAsync via DatabaseSyncToAsync.  SyncConsumer should
have a guaranteed SyncToAsync instance with threadlocal on the executor
thread, because it is running inside a SyncToAsync to begin with.  Is
that correct?

The following "works" as part of my sync consumer but I'm not positive
what the sharp edges are going to be:

     def start_coroutine(self, coroutine):
         loop = getattr(SyncToAsync.threadlocal, "main_event_loop", None)
         if not (loop and loop.is_running()):
             loop = asyncio.new_event_loop()
             asyncio.set_event_loop(loop)
         loop.call_soon_threadsafe(loop.create_task, coroutine())

Where the coroutine is anything awaitable.

The documentation at
https://channels.readthedocs.io/en/latest/topics/consumers.html goes
into the opposite scenario, using Synchronous functions such as django
ORM from an AsyncConsumer, but would really benefit from an example of
something like an idle timeout implementation for a SyncConsumer.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fb7bdf64-66e3-47d6-a3aa-6b562b0a96b4%40googlegroups.com.

TypeError: expected string or bytes-like object

Hi Folks,

After do some modification in models.py like I remove some column and add some column in my models,now I'm getting this error:

TypeError: expected string or bytes-like object


Please tell me how can i solve this problem?


Thank You

Regards,
Soumen

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WaHcREmx0Nw8NTXoxdC-fKrQKQuVMfdk5DmGz6%3DTd4yFw%40mail.gmail.com.

error in Importing 'RemovedInDjango40Warning'


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/90a94c20-b65e-4de9-b631-6b4399ec052f%40googlegroups.com.

Re: PasswordResetDoneView not using custom template in Django

could you please show the content of "PasswordResetDoneView" ?

On Thu, Aug 29, 2019 at 3:31 AM siva reddy <sivatoms@gmail.com> wrote:

PasswordResetDoneView.as_view is not loading custom template I'm using Django 2.2 version

I have created a custom template and add the path to the accounts app URL


url(r'^reset_password/done/$',PasswordResetDoneView.as_view(template_name='accounts/my_password_reset_done.html'),name='my_password_reset_done'),

My Template

{% extends 'base.html' %}    {% block body %}  <div class="container">      <h1>Password Reset Done</h1>      <p>          We've emailed you instructions for setting your password if an account exists with the email you entered. You should receive them shortly.          If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder.      </p>    </div>  {% endblock %}

The issue
if I have -
path('', include('django.contrib.auth.urls')),
in my main URL then it is loading default Django template. if I removed that I'm getting the error that path doesn't exist and I'm trying to override the Django template with my own template but it is not loading.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ab9a3d39-02ae-48c3-928d-1d1d87f508c2%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJenkLC-1C47TgJ7LiG2hCVLcmOOYpJiqk3V1TwqjZtSNM_LgQ%40mail.gmail.com.

Re: Network device automation with Django web framework

according to https://pubhub.devnetcloud.com/media/pyats/docs/getting_started/index.html, " In pyATS, test scripts are written and executed through AEtest Package".

How about parsing the results of the tests by ur own functions in the backend ? (just sharing an idea )

On Thu, Aug 29, 2019 at 8:51 PM Chandan Kumar Maiti <cmaiti@gmail.com> wrote:
As I am not an expert, I would appreciate of someone can advise me how to proceed with the following issue I am currently running into:

I am looking to build a web framework with Django to perform CISCO networking device testing automaton ( most likely using PyATS). 
So, I should be able to start my test using web interface and the Pass/Fail of my test should automatically update on the webpage and
for the failed tests , there should a link to view the logs. However, I couldn't find anything on the web to get an idea on pyAts/Django web
framework.

Does anyone have any idea on how to do this project ? is there a different approach for quicker result ?

Thanks in advance.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/799720e2-49c8-4feb-b3ca-4a3e448e5516%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJenkLDbtRZN-8bOr-hJeh9t5AG5OA7g%3Dh2yzs%2BaEONfJn%2BwyA%40mail.gmail.com.

Re:

Can You Provide Some Example

On Fri, Aug 30, 2019 at 2:47 PM Budi Hermansyah <budi.hermansyah.3g@gmail.com> wrote:
Hi Shakil, 
better you use elastic search for indexing your data from database or other tools like ES, the purpose is for indexing your data from your database.
you can create modelling in ES too for you to speed you loading data...

Hope it help you...

Regards,


On Fri, Aug 30, 2019 at 2:51 AM Shakil Ahmmed <shakilfci461@gmail.com> wrote:

Firstly I Have More than 1 Million Data In my database , while i want to perform aggregation or annotation or filter it took huge time , i have to show all data at a time,,, i use select_related() for foreign key but i want to optimize database hitting , like i want to fetch all data from database in first database hit and convert them into dictionary or list and perform another queries into dictionary or list without hitting database i hope it can optimize database hit Example : In Laravel I Fetch All data from database and convert it into Array while i have to perform queries into it i convert them into collect() and perform queries , and it dont hit the database .
[a link ]:(https://laravel.com/docs/5.8/collections) !

I Can perform this in Django ???

--

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfwCnMV_e5Th6HXTMSPQ%3DjeEFYzYjnV7WpXjvHm968mOrQ%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHGmjWXO-LabtzvOVs3s8DjojkXxQEGit1f9iS1z5n%3DspSN%3DEA%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfwPRD4DCqn4Eu-mndFesD0aTH-c04ntAkDTUcLjWvgoCA%40mail.gmail.com.

Re:

Hi Shakil, 
better you use elastic search for indexing your data from database or other tools like ES, the purpose is for indexing your data from your database.
you can create modelling in ES too for you to speed you loading data...

Hope it help you...

Regards,


On Fri, Aug 30, 2019 at 2:51 AM Shakil Ahmmed <shakilfci461@gmail.com> wrote:

Firstly I Have More than 1 Million Data In my database , while i want to perform aggregation or annotation or filter it took huge time , i have to show all data at a time,,, i use select_related() for foreign key but i want to optimize database hitting , like i want to fetch all data from database in first database hit and convert them into dictionary or list and perform another queries into dictionary or list without hitting database i hope it can optimize database hit Example : In Laravel I Fetch All data from database and convert it into Array while i have to perform queries into it i convert them into collect() and perform queries , and it dont hit the database .
[a link ]:(https://laravel.com/docs/5.8/collections) !

I Can perform this in Django ???

--

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BEpJfwCnMV_e5Th6HXTMSPQ%3DjeEFYzYjnV7WpXjvHm968mOrQ%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHGmjWXO-LabtzvOVs3s8DjojkXxQEGit1f9iS1z5n%3DspSN%3DEA%40mail.gmail.com.

Thursday, August 29, 2019

Re: Fwd: How to send emails using django rest framework from front end angular 7

Hi Sai

On 29/08/2019 12.26, Sai Aravind wrote:
>
>
> Dear members,
>
> Can anyone help me send emails from django backend with angular 7
> frontend , it's very urgent please let me if any one has done it before
>

It doesn't matter which frontend you use, Django is perfectly able to
send emails:

https://docs.djangoproject.com/en/2.2/topics/email/

Why is it relevant that you want to use Angular in the client code which
is completely isolated from the backend Python code you want to use for
sending emails?

What are you trying to achieve and which problems do you have?

Kind regards,

Kasper

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7bc71830-ae8f-804c-7c37-0cd060b6573e%40stacktrace.dk.

Re: confusing about running some codes in django

But when I put this code in model.py, when I run the server it returns an error about constraints failed but the user was added in Django admin users. Why this happen??

On Aug 29, 2019 5:54 PM, "Mario R. Osorio" <nimbiotics@gmail.com> wrote:
That code is meant for you to type it in the python console however, you could also include it pretty much anywhere in your code.


On Wednesday, August 28, 2019 at 9:15:20 AM UTC-4, Vahid Asadi wrote:
Hi . 
when i read the django docs,it suggested that running some code but it does not note that where to write this piece of code . the code is :

from django.contrib.auth.models import User
u = User.objects.get(username='john')
u.set_password('new password')
u.save()

i know that i can run it in django shell (manage.py shell)
but i want to write these in a file(its some confusing that every code in views.py should return a http response but this type of commands does not return any respone) 
where should i put this code ??
thanks for your attention.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAE-JtS84v9Jd%2BwEp2j7kqF2cPg%2BNtvO02WunQkSDneWMbHc6_g%40mail.gmail.com.

Re: confusing about running some codes in django

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd44c70e-20f3-4e99-8ca8-e24d7c91fd71%40googlegroups.com.

Re: confusing about running some codes in django

When you do a CRUD operation , you can use Django ORMs in view.py.

Regards,
Amitesh Sahay


On Thursday, 29 August, 2019, 06:54:35 pm IST, Mario R. Osorio <nimbiotics@gmail.com> wrote:


That code is meant for you to type it in the python console however, you could also include it pretty much anywhere in your code.


On Wednesday, August 28, 2019 at 9:15:20 AM UTC-4, Vahid Asadi wrote:
Hi . 
when i read the django docs,it suggested that running some code but it does not note that where to write this piece of code . the code is :

from django.contrib.auth.models import User
u = User.objects.get(username=' john')
u.set_password('new password')
u.save()

i know that i can run it in django shell (manage.py shell)
but i want to write these in a file(its some confusing that every code in views.py should return a http response but this type of commands does not return any respone) 
where should i put this code ??
thanks for your attention.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%40googlegroups.com
.

Re: confusing about running some codes in django

That code is meant for you to type it in the python console however, you could also include it pretty much anywhere in your code.


On Wednesday, August 28, 2019 at 9:15:20 AM UTC-4, Vahid Asadi wrote:
Hi . 
when i read the django docs,it suggested that running some code but it does not note that where to write this piece of code . the code is :

from django.contrib.auth.models import User
u = User.objects.get(username='john')
u.set_password('new password')
u.save()

i know that i can run it in django shell (manage.py shell)
but i want to write these in a file(its some confusing that every code in views.py should return a http response but this type of commands does not return any respone) 
where should i put this code ??
thanks for your attention.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%40googlegroups.com.

Re: Reverse for 'modification' with no arguments not found issue

My "home" variable is defined with a view :

def home(request):
    """ Acceuil du site qui recense toutes nos requêtes pour le moment """
    return render(request, 'insertion/accueil.html', locals())

Which redirect to my homepage.

The line with a problem is that one

    return render(request, 'insertion/modification.html', locals())


And I really can't figure it out why, according the fact that "locals()" contains my variable and even if I send directly my variable instead, I get the same !



Le jeudi 29 août 2019 03:55:52 UTC+2, James Schneider a écrit :


On Wed, Aug 28, 2019, 2:00 AM Ali IMRANE <ali.i...@gmail.com> wrote:
Thanks James for your help.

Indeed, I tought about that problem but I already managed to see an number on an other page, as well as using that ID to read information behind my informations (as you can see in the third line I gave on "lire.html"). A number is printed. How can I know that it is an int and not a string use in there ?

In the template it won't matter whether it is an int or a string, it gets implicitly converted to a string for the regex match anyway.



        # Nous pourrions ici envoyer l'e-mail grâce aux données
        # que nous venons de récupérer
        envoi = True
        redirect(home)


What is the home variable in the redirect statement above? It isn't defined in your view. I think that will need an extra argument. What line is the traceback actually complaining about?

-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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4e7167ae-5519-4b9a-8bad-2310e5cc5217%40googlegroups.com.